You reverted a merged feature, fixed it, and merged the branch again, but the original changes are missing. What happened?
AdvancedScenarioBranching and Merging Workflows
Answer
Situation read → Reverting a merge creates a commit that undoes the changes but leaves the original commits in history. Git thinks those commits are already merged, so a second merge brings nothing from them.
What I'd do →
- Revert the revert on
main:git revert <revert-commit-sha>. This brings the original changes back. - Merge the fixed branch; only the new fix commits are added.
- Alternative: rebase or cherry-pick the feature commits to new SHAs on a fresh branch and open a new PR.
Why → Merge logic works on commit ancestry, not content. The reverted commits remain ancestors.
Interview tip → This is Linus's well-known "reverting a merge" caveat. Naming it shows depth.
More on Branching and Merging Workflows
You run `git pull` and Git stops with a merge conflict in `app.py`. What do you do?BeginnerYour feature branch is three weeks old and `main` has moved a lot. Merge `main` in, or rebase onto it?IntermediateThe team argues about fast-forward merges versus merge commits on `main`. How do you settle it?BeginnerA teammate branched from the wrong base, and their PR shows 40 unrelated commits. How do you fix it?IntermediateBefore merging, you want to see exactly what the feature branch adds compared to `main`. Which commands?BeginnerHalfway through a merge you realise you pulled the wrong branch. How do you back out?Beginner