Merge vs Rebase: Why I Switched

This morning I said I prefer merge. This afternoon I'm going to tell you why. 🔥 I once rebased a feature branch onto main and hit a conflict on every single replayed commit. The same file, over and over, because the rebase was replaying each commit individually against a main that had diverged significantly. By the fifth resolution I wasn't even reading the diff anymore. I was just picking sides and hoping. That's not engineering. That's gambling with your codebase. I aborted, ran git reflog to confirm I could recover, and did a merge instead. One conflict. One resolution. Done. Git Recovery Cheat Sheet: ✔️ Mid-Rebase Escape: git rebase --abort (returns your branch to the exact state before the rebase started) ✔️ Already Finished a Bad Rebase: git reflog then git reset --hard HEAD@{n} (find the pre-rebase entry in reflog and reset to it) ✔️ Undo a Merge (Before Pushing): git reset --hard HEAD~1 (removes the merge commit, only safe if you haven't pushed) ✔️ Undo a Merge (Already Pushed): git revert -m 1 <merge_commit_hash> (creates a reversal commit, safe for shared branches) ⚠️ git reset --hard is destructive. It discards uncommitted work. Run git stash first if you have unsaved changes. Never use it on a branch others have pulled. 🔍 Before you run any destructive Git command, run git reflog first. Confirm you can see where you were. That's your safety net. 💾 Save this. You won't need it until you do, and when you do, you'll need it fast. #Git #GitOps #DevOps #DamnitRay

To view or add a comment, sign in

Explore content categories