Git “fatal: not a git repository”: get into the right directory
Confirm the working directory, then clone or initialize deliberately instead of guessing.
You ran git outside any repository. Check your current directory with pwd, move into the actual checkout, and only then decide between cloning the remote again or initializing a new repository on purpose.
Try these fixes in order
Confirm where the shell actually is
Run pwd to see exactly where the shell is, and ls -a (or dir /a on Windows) to see whether a .git entry exists. Terminal tabs and editor-integrated shells often start in a different folder than you assume.
Ask Git where the repository root is
From the suspected project root, run git rev-parse --show-toplevel. If it prints a path, that is the repository and your shell was simply elsewhere. If it repeats the fatal error, no repository exists at or above that directory.
git rev-parse --show-toplevelClone for existing history, init only for a new repository
If no repository exists and you want the project's history, clone it fresh with git clone <repository-url> rather than initializing. If you truly want a brand-new repository for these files, run git init deliberately and make an initial commit.
git clone <repository-url>git initRule out a path or mount mismatch
On WSL, containers, or network mounts, confirm the path is the same filesystem Git expects; a Windows path opened in WSL is a different location. After moving into the right directory, run git status to confirm Git recognizes the worktree.
Interpret what you see
The error appears for every git command in this shell
What it suggests: Git walked up from the current directory and found no .git, so the command has no repository to act on. This is about location, not corruption.
Next check: Run pwd and ls -a. If you expected a repository here, look one level up or in the directory where you cloned.
git status fails but the project files are clearly present
What it suggests: The folder may be the project but not the checkout, for example you opened the parent folder in an editor or terminal.
Next check: Run git rev-parse --show-toplevel in the directory you believe is the repo; compare it with your shell's location.
Git commands worked in this folder yesterday
What it suggests: Cloud sync tools, cleanup scripts, or an interrupted move can remove or relocate .git while leaving the worktree behind.
Next check: Search the parent directories for a .git folder and check the sync tool's trash or history before recreating anything.
Why this happens
- The command was run in a directory that is not inside a Git working tree.
- The repository's .git directory was deleted, moved, or never created there.
Still not working?
If the folder used to be a repository and .git is now missing, check backups, cloud sync history, or the shell's recent directory changes before running git init. Initializing a fresh repository over a worktree with valuable uncommitted files does not recover history, and a second .git nested inside the project will confuse future commands.
Official sources
These steps are based on the linked documentation and general diagnostics. BugMedic has not independently tested every product and system configuration. Review commands before running them.