gritHEAD → docs/merge-base
Commands / HistoryMarkdown

grit merge-base

Find common ancestors or test whether one commit is an ancestor of another.

grit merge-base <A> <B> [--all] [--is-ancestor]

Description

Finds merge bases between two commits, or checks reachability. With no flags, prints one minimal merge base (same default as Git). --all lists every minimal base (needed for criss-cross histories). --is-ancestor exits 0 when A is an ancestor of B, 1 when it is not, and prints nothing in human mode.

Options

Option Description
<A>, <B> Two commits or refs to compare.
--all List all minimal merge bases.
--is-ancestor Exit status only: ancestor test (A vs B).

JSON output

Schema: v1

Pass --json for stable, scripting-friendly output:

Field Type Meaning
merge_bases array of strings Hex object ids of merge bases (empty when --is-ancestor is set).
is_ancestor boolean or null true or false with --is-ancestor; otherwise null.

Markdown output

Schema: v1

Pass --markdown for a short heading and bullet list of merge bases, or a sentence for --is-ancestor.

Exit status

Code Meaning
0 Success, or --is-ancestor when the first commit is an ancestor of the second.
1 --is-ancestor when not an ancestor, or other failure.
2 Invalid flags (usage).

See Exit codes.