Number of Commits between two Commitishes

后端 未结 2 1439
陌清茗
陌清茗 2020-12-14 07:05

How can I find the number of commits between two commitishes in git?

Additionally, is there some way that I could do the same with any project on GitHub

2条回答
  •  [愿得一人]
    2020-12-14 07:15

    $ git log 375a1..58b20 --pretty=oneline | wc -l
    

    Specify your start commit followed by your end commit, and then count the lines. That should be the count of commits between those two commit ranges. Use the --pretty=oneline formatting so that each commit takes up a single line.

    Note that using two dots (375a1..58b20) is different than using three dots (375a1...58b20); see What are the differences between double-dot “..” and triple-dot “…” in Git commit ranges? for more information about this and to figure out which one you want to use.

    As for the GUI in GitHub, I don't know of a way to accomplish this same task. But that should be trivial, as the above is the possible way to do it directly using Git and Bash.

提交回复
热议问题