A Real Conflict, Resolved
git rebase master
# CONFLICT (content): Merge conflict in kitchen-tips.md
Both branches genuinely edited the same real file. Resolving it by hand and running git rebase --continue completes the rebase — successfully, by git's own definition.
Realizing It Was Wrong
Sometimes the "successful" resolution is not actually the one that was wanted — a real line got dropped, merged oddly, or simply does not read right on a second look.
One Command, Fully Undone
git reset --hard ORIG_HEAD
git automatically records ORIG_HEAD before rebase (and before merge, and before reset itself) as a real, one-step undo. This throws away the entire rebase — every replayed commit, every conflict resolution — landing back exactly where the branch was before git rebase ran.
feature/pantry-audit and master both genuinely edited the same real shared file. Rebasing the feature branch onto master hits a real conflict — resolved by hand, the rebase completes successfully. Only afterward does it become clear the resolution was not actually right.
Fixing a completed rebase commit by commit would mean another real interactive rebase, more conflict resolution, more risk. git sets ORIG_HEAD automatically before every real, potentially destructive operation — rebase included — as a genuine one-step undo. reset --hard ORIG_HEAD throws away the entire rebase in a single command, back to the exact real state from right before it started.
ORIG_HEAD
A real ref git sets automatically before potentially destructive operations — rebase, merge, reset itself — pointing at wherever the branch was right before. Confirmed directly in this lab: it held the exact pre-rebase tip even after the rebase completed successfully.
reset --hard ORIG_HEAD
Undoes an entire real, completed operation in one command — every replayed commit, every conflict resolution — rather than fixing it piece by piece. Confirmed directly in this lab: the branch returned to its exact pre-rebase parent and content.
Takeaways
- git sets ORIG_HEAD automatically before rebase, merge, and reset — a real, one-step undo point
- A completed rebase can still be entirely wrong — ORIG_HEAD undoes the whole thing, not just the last commit
- reset --hard ORIG_HEAD is faster and safer than trying to manually fix an already-rewritten history
- ORIG_HEAD holds only one position at a time — it is overwritten by the next destructive operation, unlike reflog's full running history