Git Error Messages Explained & Fixed
Every Git error tells a story. Find the exact message you are staring at, understand what Git is trying to say, and fix it step by step with real terminal examples.
Find your error
Each guide explains what the message means, why it happens, and how to fix it without breaking anything. Copy the message from your terminal and match it below.
fatal: not a git repositoryYou ran a Git command outside a repository, or the .git folder is missing.
Read the fixerror: failed to push some refsThe remote has commits you do not have locally. Pull, integrate, then push again.
Read the fixCONFLICT (content): Merge conflict in fileTwo branches changed the same lines. Git needs you to pick the right version.
Read the fixfatal: refusing to merge unrelated historiesThe two branches share no common commit, often after git init plus a clone.
Read the fixerror: Your local changes would be overwrittenUncommitted changes block a checkout or pull. Commit or stash them first.
Read the fixerror: remote origin already existsYou tried to add a remote named origin but one is already configured.
Read the fixerror: pathspec 'x' did not match any file(s)Git cannot find the branch or file you named. Usually a typo or a missing fetch.
Read the fixYou are in 'detached HEAD' stateHEAD points to a commit instead of a branch. Not an error, but easy to lose work.
Read the fixgit@github.com: Permission denied (publickey).GitHub rejected your SSH connection. Your key is missing or not registered.
Read the fixfatal: detected dubious ownership in repositoryThe repository folder belongs to another user. Git 2.35.2+ blocks it for safety.
Read the fixfatal: Unable to create '.git/index.lock': File exists.Another Git process is running, or a crash left a stale lock file behind.
Read the fixGitQuest is created by Anaïs (nouvelle fenêtre), web developer and head of education, specializing in tech training and digital accessibility.
Stop fearing Git errors
GitQuest turns every error into an investigation. Practice in a safe terminal simulator and build the reflexes to fix anything Git throws at you.
Download GitQuest