01
Rewriting History
Squashing, editing, and reordering commits; the cost of changing the past repository-wide; force push discipline on shared branches; and recovering lost commits with the reflog.
- 01 Interactive Rebase Changing a commit changes the identity of every commit after it; rewriting from the middle touches 252, 362, 3002, and 11322 objects in 50-, 200-, 1000-, and 4000-commit histories respectively, and the ratio stays at roughly half at every scale.
- 02 Bulk History Transformation A repository-wide transformation starts from the first commit: in a thousand-commit history, 1000 identities change, 5640 objects are touched, and the new history does not share a single commit with the old one — so every copy has to be re-cloned and the operation cannot be undone.
- 03 Force Push Discipline In a thousand-commit history, changing the last commit changes 1 identity, changing the first changes 1000; but in both cases all seven of seven copies have to resync, and the stranded local work stays the same — the cost scales with the number of copies, not the size of the change.
- 04 Reflog Rewriting does not shorten history, it doubles it: in a thousand-commit repository, a transformation from the first commit leaves 1000 commits reachable and 1000 unreachable; in a six-entry log, when the retention horizon is 7, 30, 60, and 90 days, the recoverable commits are 3, 50, 500, and 1000.