Git: How to list commits on this branch but not from merged branches

wch picture wch · Apr 20, 2012 · Viewed 52.4k times · Source

Suppose your git commit history looks like this:

A---B---C---D---E---F master
     \         /
      X---Y---Z topic

Is it possible to have git list only the commits on master, A-F? In other words, if the commit was on a merged-in branch, I don't want it show.

Answer

CharlesB picture CharlesB · Apr 20, 2012

git log has option --first-parent, so you won't get topic history.

When merged from master, the master commits are the first parents in merge. Git log allows to display only those commits with --first-parent, so you get the right stuff.