Skip to content
🌿

Git Errors

50 errors

Common Git errors and how to fix them.

50 / 50

  1. 1

    fatal: not a git repository

    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.

  2. 2

    Merge Conflict

    Git stopped mid-merge because both branches edited the same lines — you must manually choose which version to keep.

  3. 3

    Push Rejected

    Your push was rejected because the remote branch has newer commits — you need to pull and integrate them first.

  4. 4

    Detached HEAD

    You're working on a commit directly, not a branch — any commits you make won't belong to any branch and could be lost.

  5. 5

    Branch Does Not Exist

    You referenced a branch name that git doesn't know about — it doesn't exist locally or hasn't been fetched from the remote.

  6. 6

    Uncommitted Changes

    Git stopped you because switching branches or pulling would overwrite changes you haven't committed yet.

  7. 7

    Nothing to Commit

    You tried to commit, but there are no staged changes — your working tree matches the last commit.

  8. 8

    Pathspec Did Not Match

    You referenced a file that Git cannot find — it does not exist in the working directory or is not tracked.

  9. 9

    Non-Fast-Forward Push

    Your local and remote branches have diverged — the remote has commits you do not have, and you have commits it does not have.

  10. 10

    Local Changes Would Be Overwritten

    Switching branches would overwrite your uncommitted changes, so Git stopped to protect your work.

  11. 11

    Refusing to Merge Unrelated Histories

    You are trying to merge two repositories that were created independently and share no common ancestor.

  12. 12

    Unmerged Files

    A merge or rebase is in progress with unresolved conflicts — you must resolve them before committing.

  13. 13

    Bad Object Reference

    The commit hash, branch, or tag you referenced does not exist or is corrupted.

  14. 14

    Resolve Your Current Index First

    A previous merge or rebase left conflicts unresolved — you must resolve or abort before starting a new operation.

  15. 15

    Permission Denied (Publickey)

    Your SSH key is not configured correctly or is not associated with your GitHub account, so the remote rejects your connection.

  16. 16

    Remote Already Exists

    A remote with the name you specified (e.g. origin) is already configured — you cannot add it again.

  17. 17

    Protected Branch Push Failed

    The branch (e.g. main) is protected on the remote — direct pushes are not allowed. You must use a pull request.

  18. 18

    Ambiguous Argument

    The name you provided matches both a branch/commit and a file — Git does not know which you mean.

  19. 19

    Cannot Do Soft Reset With Paths

    git reset --soft cannot be used with individual file paths — it only works on the whole repository.

  20. 20

    Dirty Index During Rebase

    Git refuses to start a rebase because you have uncommitted changes that would be lost.

  21. 21

    Nothing Added to Commit

    There are new (untracked) files that have not been staged — git commit has nothing to commit.

  22. 22

    Could Not Find Remote Ref

    You referenced a remote branch that does not exist — it may not have been pushed yet or was deleted.

  23. 23

    Cannot Lock Ref

    A reference lock could not be acquired — usually due to a stale lock file or a corrupted ref state.

  24. 24

    Bad Revision

    The revision specifier you used (e.g. HEAD~5) goes beyond the beginning of history or references a non-existent commit.

  25. 25

    Invalid Object Name

    HEAD does not point to a valid commit — most commonly because no commits have been made yet.

  26. 26

    Large File Rejected

    The file you are pushing is too large for the remote (GitHub limits files to 100 MB). You need Git LFS or to remove the file.

  27. 27

    Author Identity Not Configured

    You have not configured your Git user.name and user.email, so Git cannot attribute commits to you.

  28. 28

    Rebase Conflict Not Resolved

    During a rebase, a commit could not be applied due to a conflict. You must resolve it, skip it, or abort.

  29. 29

    Stale Remote-Tracking Branch

    Your local branch has not been updated with the latest remote commits — you are behind and should pull.

  30. 30

    Accidental Force Push Data Loss

    A force push to a shared branch overwrote commits that others had pushed. The overwritten commits may be recoverable.

  31. 31

    git stash pop conflict

    You ran git stash pop but the stashed changes conflict with changes you made since stashing — git stops and leaves conflicts in your working tree.

  32. 32

    git checkout: pathspec did not match

    You told git checkout to switch to a file or branch that does not exist — git reports 'pathspec did not match any file(s) known to git'.

  33. 33

    git rebase: cannot rebase onto unrelated history

    You tried to rebase onto a branch that shares no commit history with your current branch — git blocks this to prevent losing commits.

  34. 34

    git cherry-pick: commit is empty

    You cherry-picked a commit whose changes are already present in the current branch — git reports the commit is empty or a no-op.

  35. 35

    git submodule update fails: repository not found

    You ran git submodule update but git cannot find or fetch one of the submodule repositories — the remote URL is wrong or the commit is missing.

  36. 36

    git reflog: entry expired and pruned

    You tried to recover a commit via git reflog but the entry was already pruned by git gc — the commit hash is no longer in the reflog.

  37. 37

    git gc: too many loose objects error

    You ran git gc and it failed because the repository accumulated too many loose objects — packing them exceeded available memory or disk space.

  38. 38

    git hook: permission denied / bad interpreter

    Your git hook in .git/hooks/ is not running because the file is not executable or the shebang line points to a non-existent interpreter.

  39. 39

    git config: invalid key format

    You passed a malformed key to git config — the key must follow the format section.subsection.variable with valid characters.

  40. 40

    gitattributes: invalid pattern or attribute

    Your .gitattributes file has a line with a malformed path pattern or a typo in an attribute name — git warns or ignores the entry.

  41. 41

    gitignore: pattern not matching as expected

    You added a pattern to .gitignore but files are still tracked — the pattern syntax or anchoring does not match the file paths.

  42. 42

    git merge: invalid strategy specified

    You passed an invalid merge strategy to git merge -s — only recursive, ort, resolve, ours, theirs, subtree are built-in strategies.

  43. 43

    git tag: invalid tag name format

    You tried to create a tag with a name containing spaces, colons, or other forbidden characters — git rejects it as an invalid ref name.

  44. 44

    Accidentally committed to wrong branch

    You committed work to the wrong branch — the commit is on main but should be on a feature branch, and you need to relocate it safely.

  45. 45

    Stale remote-tracking branch after force push

    A teammate force-pushed to a shared branch, and your local remote-tracking ref still points to the old history — pulling creates conflicts or duplicate commits.

  46. 46

    Rebase instead of merge confusion

    You rebased when you meant to merge (or the reverse), producing a linear history instead of a merge commit — teammates may see rewritten commits.

  47. 47

    git reset --hard caused data loss

    You ran git reset --hard and lost uncommitted working tree changes — the changes were not stashed or committed, so they are gone from the working tree.

  48. 48

    git pull silently created merge commit

    You ran git pull and got a merge commit you did not expect — the default pull strategy merged instead of fast-forwarding or rebasing.

  49. 49

    Orphaned commits after rebase

    You rebased and the original pre-rebase commits are now orphaned — they exist in the object store but no branch or tag points to them.

  50. 50

    git am: patch format corruption

    You ran git am with a patch file that has corrupted or malformed mbox format — git cannot parse the commit metadata or diff content.

← Back to errors