Error Fix

How to Fix 'not a git repository'

A quick fix path for wrong directories, missing .git metadata, and command context mistakes.

Git shows this when the current directory is not inside a repository or the repository metadata is missing or damaged. In many cases, you are simply in the wrong place.

Best Fixes

Check the current directory and move to the actual repository root or one of its subdirectories.

If the project should be a repository but `.git` is missing, confirm whether it was removed, never initialized, or replaced by a fresh copy.

Avoid This

Do not run Git repair commands until you know whether you are just in the wrong directory.

Do not initialize a new repo on top of an existing project until you confirm that is what you want.

Save commands, add notes, and build a Cheatbook with the fixes you want to keep handy.