git Errors
10 error patterns
git3 fixes
Merge conflict
CONFLICT \(content\): Merge conflict in (.+)
- •Open conflicted files, resolve the <<<<<<< / ======= / >>>>>>> markers, then `git add` and `git commit`
- •Use a merge tool: `git mergetool` (configure with `git config merge.tool <tool>`)
git3 fixes
Detached HEAD state
You are in 'detached HEAD' state
- •Create a branch to keep your work: `git checkout -b my-branch`
- •Return to a branch: `git checkout main` (commits in detached HEAD may be lost without a branch)
git3 fixes
Push rejected — remote has new commits
\! \[rejected\].*\(fetch first\)|failed to push some refs.*Updates were rejected
- •Pull and rebase: `git pull --rebase origin <branch>` then push again
- •Pull and merge: `git pull origin <branch>` then resolve conflicts and push
git3 fixes
Rebase conflict
CONFLICT.*could not apply|error: could not apply
- •Resolve conflicts in the listed files, then `git add .` and `git rebase --continue`
- •Skip the problematic commit: `git rebase --skip` (loses that commit's changes)
git3 fixes
Stash apply conflict
CONFLICT.*in.*stash|error:.*could not apply.*stash
- •Resolve the conflicts manually, then `git add .` — the stash remains in the list for safety
- •Drop the stash after resolving: `git stash drop stash@{0}`
git3 fixes
SSH permission denied
Permission denied \(publickey\)|Could not read from remote repository
- •Check your SSH key is added to the agent: `ssh-add -l` — if empty, run `ssh-add ~/.ssh/id_ed25519`
- •Verify the key is added to your Git hosting account (GitHub/GitLab/Bitbucket Settings → SSH Keys)
git3 fixes
Git LFS smudge/download error
git-lfs.*smudge.*error|batch response.*Git LFS
- •Run `git lfs install` to ensure LFS hooks are set up
- •Fetch LFS objects: `git lfs pull` or `git lfs fetch --all`
git3 fixes
Submodule initialization failure
fatal: No url found for submodule path|Submodule.*registered for path.*not found
- •Initialize submodules: `git submodule init && git submodule update --recursive`
- •Re-clone with submodules: `git clone --recurse-submodules <url>`
git3 fixes
Divergent branches — no reconciliation strategy
fatal: Need to specify how to reconcile divergent branches
- •Set default pull strategy: `git config pull.rebase true` (rebase) or `git config pull.ff only` (fast-forward only)
- •One-time fix: `git pull --rebase origin <branch>` or `git pull --no-rebase origin <branch>`
git3 fixes
Lost commits — reflog recovery
fatal: bad default revision 'HEAD'|reflog.*not found|HEAD is now at
- •Find the lost commit SHA: `git reflog` shows all recent HEAD movements
- •Restore with: `git checkout <sha>` then `git checkout -b recovery-branch`