Git Emergency
My pull request is behind main
Severity Minor
What just happened
Other PRs were merged since yours was created. The repository requires branches to be up to date before merging, so your tests run against the final code.
Potential risks
- None, unless conflicts show up (see “My pull request has conflicts”).
Before you run anything
- The “Update branch” button on GitHub does the merge for you.
Recovery steps
- 1
How far behind?
The commits of main your branch doesn't have.
Safe$ git fetch origin$ git log HEAD..origin/main --oneline - 2
Update with a merge
Simple, no history rewrite.
Safe$ git merge origin/main$ git push - 3
Or with a rebase
Cleaner history, needs a force push with lease.
Caution$ git rebase origin/main$ git push --force-with-lease
These procedures are provided for information only. Read each command and adapt it to your situation before running it. Disclaimer
Other disasters
🪓 I deleted my branch🚨 I pushed directly to main💥 I ran git reset --hard🧨 I overwrote a colleague's commits🔑 I pushed my .env file to GitHub🔀 I made a bad merge👻 I lost uncommitted changes🎯 I committed on the wrong branch🎈 I'm in “detached HEAD” state⚔️ I'm stuck in a merge conflict🚫 My push is rejected (non-fast-forward)🌀 My rebase went wrong🐘 GitHub rejects a file over 100 MB🥸 I committed with the wrong name or email🗑️ I deleted a file and committed it⏪ I want to undo my last commit✏️ I amended a commit that was already pushed🧹 Too many messy commits to clean up📮 I pushed to the wrong branch🧭 I rebased onto the wrong branch🔁 I need back the changes I reverted📦 git stash pop gave me a conflict🙈 I committed a file that should be ignored🔠 Git doesn't see my file rename (upper/lower case)🧨 I ran git clean -fd by mistake🩻 My repository is corrupted🙃 I forgot to pull before pushing👯 Duplicated lines of code after a merge➖ I added a file I didn't want to (git add)✏️ I made a typo in a commit message✂️ My commit does too many things🧺 I lost a stash (drop, clear or pop gone wrong)🫥 I pulled and my code disappeared🍒 I cherry-picked the wrong commit☁️ I deleted a branch on GitHub / GitLab👥 I pushed with the wrong GitHub account🚚 The repository was renamed or moved🏷️ I tagged the wrong commit🌊 Git says every file is modified, but I changed nothing📦 I committed node_modules (or a build folder)📂 I ran git init in the wrong folder🧨 My pull request has conflicts📝 I have to apply review changes to my PR🧳 My PR shows commits that aren't mine🎯 I opened my PR against the wrong branch🚨 A merged PR broke main🚪 I closed my PR (or deleted its branch) by mistake🔴 The checks of my PR are failing🐘 My PR is too big to review🍴 My fork is behind the original repository