Git fatal: not a git repository - Rocketeers app

  [ Rocketeers ](/)   

[Login](https://rocketeersapp.com/login) 

 On this page

 Knowledge
---------

Git fatal: not a git repository
===============================

### [\#Git](https://rocketeersapp.com/knowledge/git)

This error means you ran a git command somewhere git does not recognise as a repository. Usually you are in the wrong directory, or the repo was never initialised.

 Published by [Mark van Eijk](https://rocketeersapp.com/author/mark-van-eijk) on June 23, 2026 · 1 minute read

1. [About the error](#content-about-the-error)
2. [Why do I see this error](#content-why-do-i-see-this-error)
3. [Solution](#content-solution)
4. [Check where you are](#content-check-where-you-are)
5. [Initialise a new repository](#content-initialise-a-new-repository)
6. [Clone instead, if the project lives on a remote](#content-clone-instead-if-the-project-lives-on-a-remote)
7. [Find the repository root from a subdirectory](#content-find-the-repository-root-from-a-subdirectory)

[\#](#content-about-the-error "Permalink")About the error
---------------------------------------------------------

 ```
fatal: not a git repository (or any of the parent directories): .git

```

Git commands operate on a repository, identified by a `.git` directory. When you run a git command, git looks in the current directory and walks up through the parents searching for `.git`. If it never finds one, you get this error.

[\#](#content-why-do-i-see-this-error "Permalink")Why do I see this error
-------------------------------------------------------------------------

- You're in the **wrong directory**, outside the project, or one level above it.
- The directory was never initialised as a git repository.
- The `.git` directory was deleted (sometimes accidentally, sometimes by an over-broad clean).
- You cloned into a subdirectory and are running git from the parent.

[\#](#content-solution "Permalink")Solution
-------------------------------------------

### [\#](#content-check-where-you-are "Permalink")Check where you are

First confirm your location and whether a `.git` directory exists here:

 ```
pwd
ls -la       # look for a .git entry

```

If you don't see `.git`, you're either in the wrong place or this isn't a repo. `cd` into the actual project directory:

 ```
cd ~/Sites/my-project
git status

```

### [\#](#content-initialise-a-new-repository "Permalink")Initialise a new repository

If this directory *should* be a repository but never was, create one:

 ```
git init

```

### [\#](#content-clone-instead-if-the-project-lives-on-a-remote "Permalink")Clone instead, if the project lives on a remote

If the code already exists on GitHub and you just don't have it locally, clone it rather than init:

 ```
git clone git@github.com:you/my-project.git
cd my-project

```

### [\#](#content-find-the-repository-root-from-a-subdirectory "Permalink")Find the repository root from a subdirectory

If you're somewhere inside a repo but a parent got confused, this prints the top level (or errors if you're truly outside one):

 ```
git rev-parse --show-toplevel

```

If you recently saw [refusing to merge unrelated histories](/git-refusing-to-merge-unrelated-histories) and then this, a deleted or recreated `.git` directory is a likely common cause.

### Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

  Fill in your email address to receive updates  Subscribe 

#### More in [\#Git](https://rocketeersapp.com/knowledge/git)

- [Removing tracked files in Git that should have been ignored](https://rocketeersapp.com/knowledge/removing-tracked-files-git)
- [Change casing of file or directory in Git](https://rocketeersapp.com/knowledge/change-casing-of-file-or-directory-in-git)
- [Git fatal: refusing to merge unrelated histories](https://rocketeersapp.com/knowledge/git-refusing-to-merge-unrelated-histories)
- [GitHub Permission denied (publickey)](https://rocketeersapp.com/knowledge/github-permission-denied-publickey)
- [Git: Updates were rejected (non-fast-forward)](https://rocketeersapp.com/knowledge/git-updates-were-rejected-non-fast-forward)
