A commit from three days ago should never have been made. How do you remove it from your private branch?
IntermediateScenarioRebase, Cherry-pick and History Rewriting
Answer
Situation read → The commit is in the middle of history and unshared.
What I'd do →
git rebase -i <bad-sha>^.- Change
picktodropon that line (or delete it). - Resolve conflicts from later commits that depended on it.
git push --force-with-lease.
Why → Rebase replays everything except the dropped commit. If the branch is shared, use git revert instead.
Interview tip → Ask whether anyone else has the branch before dropping anything.
More on Rebase, Cherry-pick and History Rewriting
Your PR branch has ten commits like "wip", "fix typo", "oops". How do you clean it up before review?BeginnerYou want the database migration commit to come before the code that uses it.BeginnerA critical fix on `main` must go to the `release/4.1` branch only.BeginnerYou must backport a feature made of 6 commits, including one merge commit.IntermediateBranch B was built on top of branch A. A was squash-merged into `main`, and now B shows A's commits again.IntermediateDuring review you get ten small change requests on old commits. How do you apply them cleanly?Intermediate