Git: fatal: not a git repository

Every git command answers with 'fatal: not a git repository'. Git isn't broken — you're just standing in a directory it doesn't track. Here's how to tell where the boundary is and fix it.

BytExplorer 4 min read July 1, 2026

You type git status and Git refuses:

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

Git tracks a project by a hidden .git folder at its root. When you run a Git command, it looks in the current directory and walks upward searching for that .git. This error means it reached the top of the filesystem without finding one — you're simply not inside a repository.

Cause 1: You're in the wrong directory

The most common case. You opened a terminal in your home folder, or cd'd one level too high. Check where you are and whether a .git exists:

pwd
ls -a          # look for a .git entry

If there's no .git here, move into the project that has one:

cd ~/projects/my-app
git status

Cause 2: You never initialised the repo

If this folder is a brand-new project that was never a repo, create one:

git init

That makes the .git directory, and Git commands start working from here down.

Cause 3: You meant to clone

If the code lives on GitHub/GitLab and you don't have a local copy yet, clone it instead of git init:

git clone https://github.com/you/my-app.git
cd my-app

git init turns the current empty folder into a repo; git clone downloads an existing one. Using init when you meant clone leaves you with an empty repo and no history — a classic mix-up.

Cause 4: The .git folder got deleted

Rare, but if someone removed .git, the folder stops being a repo and all history with it. If it was pushed to a remote, re-clone; if not, that history is gone.

The checklist

  1. pwd and ls -a — are you where you think you are, and is there a .git?
  2. Wrong place → cd into the real project.
  3. New project → git init.
  4. Code is remote → git clone it.
Put it into practice

Stop reading, start building

This pairs with a hands-on BytExplorer course — do it on your own machine and actually keep the skill.

More in Troubleshooting