skip to content
Alvin Lucillo

Verify commit ancestry

/ 1 min read

To check if a commit is ancestor of another commit, use git merge-base --is-ancestor <commit1> <commit2> where commit1 is the ancestor and commit2 the descendant. If it returns 0, it’s true, otherwise, false.

git merge-base --is-ancestor \
  533980c988e5721d87e37e4db6fd75d97422ba4f \
  33d0c022eae532bdf70d3d5faa0f5f90bbb5a1e2

echo $?
0