git
Lost commits — reflog recovery
fatal: bad default revision 'HEAD'|reflog.*not found|HEAD is now at
Fixes
- 1.Find the lost commit SHA: `git reflog` shows all recent HEAD movements
- 2.Restore with: `git checkout <sha>` then `git checkout -b recovery-branch`
- 3.Reset to it: `git reset --hard <sha>` (if on the correct branch and sure about losing current state)
reflogrecoveryreset
Related Errors
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