Skip to content

fatal: not a git repository

Error message

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

Quick summary

You ran a git command in a directory that isn't inside a git repo — there's no `.git` folder in this or any parent directory.

Why this happens

  • You're not inside a git repository — git init was never run here

  • The .git folder was deleted or corrupted

  • You're in the wrong terminal directory

Minimal example

✗ Broken code
cd /tmp
 git status  # fatal: not a git repository
✓ Fixed code
cd /tmp/my-project
git status  # works — inside a repo

Running git status in /tmp fails because it's not a git repo — cd into the project directory that has a .git folder first.

How to diagnose

  • Run git status — if it fails, you're not in a repo

  • Check for a .git folder with ls -a

  • Verify your current directory with pwd — are you in the project folder?

How to fix

  • Run git init to create a new repository in this directory

  • Change directory (cd) to the correct project folder

  • Clone the repository again if the .git folder is missing

How to prevent

  • Always run git status first to confirm you're in a repo

  • Use terminal prompts that show the git branch to avoid confusion

Related Resources

Related Glossary

Related Lessons

Related Practice

← Back to language