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 initwas never run hereThe
.gitfolder was deleted or corruptedYou're in the wrong terminal directory
Minimal example
cd /tmp
git status # fatal: not a git repositorycd /tmp/my-project
git status # works — inside a repoRunning 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 repoCheck for a
.gitfolder withls -aVerify your current directory with
pwd— are you in the project folder?
How to fix
Run
git initto create a new repository in this directoryChange directory (
cd) to the correct project folderClone the repository again if the
.gitfolder is missing
How to prevent
Always run
git statusfirst to confirm you're in a repoUse terminal prompts that show the git branch to avoid confusion
Related Resources
Related Glossary
Related Lessons
- What is a Repository?
Learn about git repositories
- git init
Related Practice
- Git Add Command Quiz
Test your understanding of basic Git commands.