Git log to get commits only for a specific branch

后端 未结 12 1693
挽巷
挽巷 2020-11-29 15:13

I want to list all commits that are only part of a specific branch.

With the following, it lists all the commits from the branch, but also from the parent (master)

12条回答
  •  醉梦人生
    2020-11-29 15:31

    git rev-list --exclude=master --branches --no-walk
    

    will list the tips of every branch that isn't master.

    git rev-list master --not $(git rev-list --exclude=master --branches --no-walk)
    

    will list every commit in master's history that's not in any other branch's history.

    Sequencing is important for the options that set up the filter pipeline for commit selection, so --branches has to follow any exclusion patterns it's supposed to apply, and --no-walk has to follow the filters supplying commits rev-list isn't supposed to walk.

提交回复
热议问题