Skip to main content

Notebook entry

Two Git recovery tricks I keep coming back to

Lovell Felix 1 min read

Archive note: the tools and versions have moved on. I have kept this entry because the debugging path and the underlying constraint may still be useful.

Two small Git situations that come up often enough to be worth writing down, rather than re-deriving from git help every time.

Undoing a rebase that went wrong

git rebase rewrites history, and every point it passes through along the way is still recoverable from the reflog, even after the rebase finishes:

The reflog is the safety net that makes rebasing locally low-risk. It's local-only and expires after a while (90 days by default), so this works for "I rebased five minutes ago and regret it," not for recovering history from months back.

Resetting the author on every commit

Useful after importing a repository with a placeholder author, or fixing a misconfigured user.email that leaked into a run of commits:

filter-branch rewrites every commit in the range, so every hash after the first affected commit changes. Fine on a repo only you have a copy of; coordinate with anyone else who has a clone before doing this on something shared, since their next pull will look like a wall of conflicts.

About the author

Lovell Felix

Infrastructure and reliability engineer working on Linux platforms, configuration delivery, and deployment safety at fleet scale.

@lovellfelix

Continue through the notebook