show commits since branch creation

后端 未结 7 893
伪装坚强ぢ
伪装坚强ぢ 2020-12-12 17:44

Is there a way to see with git log or some other command only the commits that were added after branch creation?

usage: git log [         


        
7条回答
  •  悲&欢浪女
    2020-12-12 18:34

    I was incorrect with my original answer. You want the double dot notation:

    git log master..
    

    I got different results than I was expecting, so I did a test with the following repo structure:

    a - - c - e - - g - i   master
      \ b - d / \ f - h     test
    

    I then tried git log master..test:

    f - h
    

    And then git log master...test:

      - g - i
      f - h
    

    So double dot shows the commits in test but not in master (^master temp) and triple dot shows commits in master AND test but not in both.

    The other excellent answer in this question got it right first and has a better explanation (https://stackoverflow.com/a/24769534/1185838); it should probably be marked as the answer instead of mine. You can also reference this answer (https://stackoverflow.com/a/463027/1185838) which helped me better understand the difference between double dot and triple dot notation.

    Apologies for the incorrect answer!


    Old Answer - Incorrect

    Use three periods to reference the commit at which the second branch diverged from the first, or in this case your branch diverged from master:

    git log master...
    

    Make sure to use three periods for this case.

    Side-Note: You can also leave off your branch name as git automatically references the HEAD pointer in that case, for example:

    git log master...
    

    is equivalent to my previous example. This works anywhere a commit comparison is available.

提交回复
热议问题