Skip to content

/errors/git/not-a-git-repository

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

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · git version 2.55.0.windows.5updated 2026-10-20
tool
Git
exit code
128
versions
Git 2.x
os
linux, macos, windows

Git prints fatal: not a git repository (or any of the parent directories): .git and exits with status 128 when it cannot find a .git directory in the current folder or any folder above it. Run the command from inside the repository, or create one with git init.

Reproduce the error

bash
mkdir not-a-repo && cd not-a-repo
git status

Output · exit 128

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

Check where you are

bash
git init -q -b main project
cd project && mkdir -p src/deep && cd src/deep
git rev-parse --is-inside-work-tree
git rev-parse --show-toplevel | sed 's|.*/||'

Output

true
project

Inside any subfolder, Git walks up until it finds .git; --show-toplevel prints that root (the last path segment is shown here).

Fix

  • Wrong folder: cd into the project, then run the command again.
  • No history yet: git init, then git add and git commit.
  • Code from a ZIP download: the archive has no .git. Use git clone <url> instead.
  • Environment overrides: GIT_DIR and GIT_WORK_TREE take precedence over the folder search. unset GIT_DIR GIT_WORK_TREE if they are set by mistake.

FAQ

How do I check whether I am inside a repository?

git rev-parse --is-inside-work-tree prints true inside a work tree and fails with exit status 128 outside one. git rev-parse --show-toplevel prints the repository root.

Sources