Rebase Changes Commit Ancestry

Rebase reapplies changes from one line of work on another base. The resulting commits have new ancestry and may have different contents after conflicts.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace one reapplied change
  2. Review the combined behavior
  3. Draw the commit whose parent changes
  4. Check whether reapplying the change keeps its semantics

Trace one reapplied change

If D originally follows A and the new base is B, the reapplied result D prime has parent B. A commit ID includes the parents, so the old and new commit identities differ. See commit snapshots.

Review the combined behavior

A patch that applied cleanly can still interact with a rule introduced in B. Check the resulting diff and run tests from the new tip. If others build on the published old tips, consider their shared branch history when coordinating.[1]

Draw the commit whose parent changes

Local commit B follows A, while upstream C also follows A. Rebasing the local change onto C may create B′ whose parent is C. Even with similar content changes, B′ has a different identity because its parent and potentially other metadata changed. See commit snapshots and parents.

Before: A→B and A→C
After replay: A→C→B′
Branch points to B′
Original B can still be referenced elsewhere

Check whether reapplying the change keeps its semantics

Different base code can require a conflict resolution or can change behavior without one. Review the rewritten range and test it against the new base. Coordinate shared history changes with the work's owners.

References

  1. Scott Chacon and Ben Straub, Pro Git ↩