Search code examples
gitbranchgit-branchgit-log

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


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.


Solution

  • 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.