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

前端 未结 4 1212
小蘑菇
小蘑菇 2020-12-02 09:58

Suppose your git commit history looks like this:

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

Is it possible to hav

4条回答
  •  心在旅途
    2020-12-02 10:03

    Answer by Charles works for me.

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

    But If you are using any graphic user interface for your Git activities like, Git Extension, SourceTree, Tortoise Git,

    Then there are direct options to check the first parent in your tools. I thought to add this answer to the list as most the people find Graphic Interface easy. and You can directly cherry pick all the commits from that particular branch from tool, if required.

    I have attached the example of two tools, It would be similar for other tools as well: [I have blured the username, git repo name as this is a private repository, but still you can get an idea how to use first parent from tools]

    1. Git Extension
      • Open Git Extension -> Checkout the feature branch you want to see the commits, there is a option to select first commits as shown in Image:

    1. Tortoise Git
      • Open the repository folder -> Click on Show logs from Tortoise Git -> Checkout the branch and select first commits as shown in Image

提交回复
热议问题