Where Did the Branch Commits Go in Git’s First-Parent Log?

A first-parent log can omit commits that are still reachable. Check exact ancestry, then choose a commit range or a tree diff to answer the right question.

Share
An illuminated orange commit rail with a dimmer branch joining it through a metal aperture.

A feature is on main, but its commit is nowhere in the release log. Before you assume somebody rebased it away, check whether the log uses --first-parent. At a merge, that option walks back through the branch that received the merge and skips the other parent paths. The feature commit can be reachable from main even though the release log never prints it. Use git merge-base --is-ancestor to check whether the exact commit is reachable.

This is an AI-prepared, documentation-based explainer, not a personally reproduced incident. The history below is illustrative. See the editorial policy.

One branch tip, two useful views

Imagine main contains a release preparation commit while a feature branch contains two changes of its own. You merge the feature into main with a merge commit. The merge records the old main tip as its first parent and the merged feature tip as another parent. Starting at the merge, a normal walk can follow both paths. The Git log documentation describes how --first-parent follows only the first parent when it encounters a merge.

That's useful for release notes: you see the merge as one event on the integration branch rather than seeing every fixup commit inside it. The catch is that this view answers “what landed along this line?” It can't answer “can I reach this exact commit from this tip?” The release summary didn't lose your commit. It just wasn't hired to find it.

Check the graph before you check the patch

These commands are for an illustrative merge commit at main; substitute the actual tip and feature commit when diagnosing a real repository. Use the same starting tip for both logs and leave out path filters while checking ancestry.

git log --first-parent --oneline main
git log --graph --oneline main
git merge-base --is-ancestor <feature-commit> main

The ancestry check exits with status 0 when the first commit is an ancestor of the second, and 1 when it isn't. Treat other nonzero results as errors. In particular, make sure the commit resolves locally and check for a shallow checkout with git rev-parse --is-shallow-repository. A shallow clone can be missing the very part of history you need, even when it builds the current tree just fine.

If the commit is absent from the first-parent log but the ancestry test succeeds, you've found a traversal difference. If the test fails with complete history, inspect how the work was integrated. Squash merges and rebases can produce different commits containing the same changes; a negative ancestry result only says that that commit object isn't an ancestor. Conversely, an ancestor can still be reachable after its changes were reverted. Debugly's merge revert explainer traces that case separately.

Choose the comparison your automation needs

If you need to inspect the commits introduced by one merge relative to its first parent, use the revision range MERGE^1..MERGE, without adding --first-parent. It lists commits reachable from the merge but not its first parent, including the merge itself. If you need the net file change at that integration point, compare the two trees instead:

git log --oneline MERGE^1..MERGE
git diff MERGE^1 MERGE

Here MERGE stands for the merge commit, not a literal name. The range can include a commit whose change was undone later on the branch. The diff only shows the net difference between the two trees, including the effect of any merge conflict resolution. Neither answer can stand in for the other.

Keep the first-parent walk for a release timeline. For an audit that promises to inspect every introduced commit, test the range on a fixture with a merge and put one uniquely identifiable change on the second-parent path. Verify that the timeline stays short and the audit still sees the change. That test catches a log option quietly changing the question your automation answers.