After a history rewrite, how do you get all contributors back in sync safely?
AdvancedProductionRecovery and incident handling
Answer
Announce the cut-over and freeze merges, have everyone re-clone or run a documented reset, and close or retarget open PRs. Old clones that push can reintroduce removed history, so add a pre-receive or ruleset check for the old root commit if necessary.
git fetch origin
git reset --hard origin/main
git reflog expire --expire=now --all && git gc --prune=now
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