Recognizing a Fast-Forward Update

A branch can fast-forward when its existing tip is an ancestor of the requested new tip, so updating the reference does not discard its ancestry.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Draw two tips
  2. Choose by graph structure
  3. Verify that the old tip is an ancestor of the proposed tip
  4. Verify ancestry in the graph

Draw two tips

If main is at A and a topic tip B has parent A, moving main to B preserves A in its history. If main independently advances to C from A, moving it straight to B would drop C from that branch history. See branch references.

Choose by graph structure

A fast-forward does not require a new merge commit. A divergence can require a merge or another chosen integration strategy. Merge commit parents explain how one new commit can retain both histories.[1]

Verify that the old tip is an ancestor of the proposed tip

Given A→B→C where arrows point from parent to child, moving a branch from A to C retains A in reachable history. If D is a sibling of C with parent B, moving from C to D does not retain C. Both possibilities can have recent commit dates. See branch pointers.

Update A→C: A ancestor of C → fast-forward
Update B→D: B ancestor of D → fast-forward
Update C→D: C not in D ancestry → non-fast-forward

Verify ancestry in the graph

A fast-forward may traverse more than one commit or pass through a merge. Order of wall-clock dates is insufficient to prove ancestry. Check the exact reference being updated and the server's branch policy.

References

  1. Scott Chacon and Ben Straub, Pro Git ↩