Interview Prep/Git & GitHub/Recovery and incident handling

Someone force-pushed over main and 12 commits vanished. How do you recover?

IntermediateProductionRecovery and incident handling
Answer

Find the old tip: from a teammate's clone or CI runner (git reflog, origin/main@{1}), GitHub's push events API or the Activity view on the branch, or the PR refs. Then restore with a force push, which needs a temporary ruleset bypass.

gh api repos/ORG/REPO/activity -f ref=refs/heads/main -f activity_type=force_push
git push --force-with-lease=main:<bad-sha> origin <good-sha>:main
All Git & GitHub questions Roadmap: Git & GitHub

More on Recovery and incident handling