If you’ve ever worked on a large project, chances are you’ve encountered a pull request (PR) disaster. Here's how I royally messed up a PR—and how Git commands saved my ass.
The Setup to Disaster
I started by branching out changes from two unmerged PRs, creating a new "combined" branch (PR 3) to merge the changes from PR 1 and PR 2.
Everything seemed fine until I noticed PR 3 was st
ill showing changes from one of the unmerged PRs. Thinking a rebase from PR 2 would fix it, I went ahead confidently.
Spoiler: I was wrong.
The rebase changed the base branch of PR 3 to PR 2, exposing all changes from PR 1.
Trying to fix this, I thought I could simply change the base branch on GitHub.
Salt in the wound: I selected the wrong branch in GitHub’s dropdown.
actual:
long-description-combine-a-deploy
long-description-combine-a
irl:
long-description-combine-..
long-description-combine-..
GitHub instantly closed my PR because the content didn’t match.
Thankfully, I had PR 3 branch stored in another backup repo. I forced-pushed this backup to PR 3, thinking all was well. But when I double-checked, the backup branch was missing my latest commit.
I’d lost my work, and my commit was nowhere to be found.
The Recovery Plan
Here’s how I saved my ass:
git reflog
c3d4f5b (HEAD -> feature) HEAD@{0}: commit: My precious changes
a1b2c3d HEAD@{1}: part of pr3 commit
9e8f7a6 HEAD@{2}: part of pr3 commit
git reset HEAD@{0}
All was well again.
Saviour article
https://medium.com/@krokowski.dx/how-to-undo-your-git-failure-b76e31ecac74

SOCIAL SHARE CARD GENERATOR