Verify a Rewritten Commit Series with Range-Diff
Review three distinct kinds of evidence
After rewriting a private branch, an attractive history graph is not enough. Compare commit sequence, final snapshot, and actual behavior. The rescue-feature branch from any completed scenario anchors the original tip; main is the unchanged common base. Check the current branch and ensure the old reference still points where expected. In production record the original hash before rewriting as well.
git log --graph --oneline --allgit log --reverse --format=%s main..rescue-featuregit log --reverse --format=%s main..HEADCompare the patch series
Range-diff pairs similar commits using their patches and metadata. It can show changed order, changed messages or changed patches. The familiar markers =, !, < and > mean matching, changed, old-only or new-only entries in the comparison. A split or squash can change pairing, so an unmatched commit is not automatically lost work. Treat its output as a human review aid, not a stable machine interface. The fixture uses simple linear series; merge-heavy history requires separate review.
git range-diff main..rescue-feature main..HEADCompare final trees and verify behavior
For a cleanup intended to preserve final content, compare tree IDs and diff exit status. Equal tree IDs in the same repository prove equality of recorded tree structure and contents, not equality of commit identity, untracked data, author information or runtime behavior. The lab checks the exact notes and light contents, paths of split commits and a clean status. In a software project, run relevant tests and check intermediate commits where useful.
git rev-parse "rescue-feature^{tree}" "HEAD^{tree}"git diff --exit-code rescue-feature HEADgit status --shortKeep a recovery path
If the rewrite is wrong after completion, do not call rebase --abort; there is no active operation. Inspect or switch to a new branch at rescue-feature after checking for uncommitted work. Keep both versions while comparing and deciding how to proceed. No push is needed in this private laboratory. Practice: if the final tree is identical but a middle commit fails a test, is the cleanup necessarily acceptable? No; the team may require every commit to remain testable. Next chapter studies reset, reflog and recovery limits.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Verify a Rewritten Commit Series with Range-Diff — knowledge check
Reason about private history editing and verification.
What does range-diff compare?
What do identical tree IDs prove here?
Can split commits appear unmatched in range-diff?
What should you do after a completed but incorrect rewrite?
Does final tree equality guarantee testable intermediate commits?