A teammate rebased a shared branch and now everyone has duplicate commits. How do you repair it?
AdvancedProductionRecovery and incident handling
Answer
Pick the canonical history (the rebased one), have each person fetch and move their unpushed local work onto it using git rebase --onto, and discard their stale copies. The key command is to replay only their unique commits.
git fetch origin
git rebase --onto origin/feature <old-upstream-sha> my-local-feature
More on Recovery and incident handling
Someone force-pushed over main and 12 commits vanished. How do you recover?IntermediateAfter recovery, what do you change so a force-push to main cannot happen again?AdvancedA bad migration commit was deployed. Walk through your response in the first 15 minutes.IntermediateHow do you recover a deleted repository or branch on GitHub?IntermediateHow do you find who or what pushed a specific commit to a protected branch?AdvancedCI is red on main after a merge. What is your policy?Intermediate