How to show git commit using number of commits since a tag

后端 未结 8 1177
执笔经年
执笔经年 2021-02-05 07:39

With git describe you can get the number of commits since the last tag. If you only had the tag and the number of commits what is the best way to show the commit t

相关标签:
8条回答
  • 2021-02-05 07:58

    If you are looking for the number of commits since the last tag, the following worked for me

    git rev-list  `git rev-list --tags --no-walk --max-count=1`..HEAD --count
    
    0 讨论(0)
  • 2021-02-05 08:00

    Try the following, if you want to get the number of commits since last tag.

    git rev-list $(git describe --abbrev=0)..HEAD --count
    
    0 讨论(0)
  • 2021-02-05 08:14

    You can:

    git log --oneline tag.. | wc -l
    

    this will give you the number of commits

    0 讨论(0)
  • 2021-02-05 08:15

    Try

    git rev-list tag..HEAD --count
    

    OR

    git rev-list tag.. --count
    

    They mean the same thing.

    0 讨论(0)
  • 2021-02-05 08:16

    This will give you the number of commits between these two commit.

    $ git log --oneline 8a32722def6b80e343...e817c082323e65bb1053

    0 讨论(0)
  • 2021-02-05 08:17

    As Kevin's answer explained, this is generally not possible. To solve the problem for special cases he mentioned:

    That said, if you don't have a bunch of parallel branches going on at once, then you may be able to resolve a given commit number back to a single commit, but if you have even a single active side branch at the time of your tag then this may not work.

    you can use the following command (with n being the number of commits since the tag)

    git rev-list tag..HEAD --reverse | awk NR==n
    
    0 讨论(0)
提交回复
热议问题