Get all git commits since last tag

前端 未结 2 2018
没有蜡笔的小新
没有蜡笔的小新 2021-01-29 21:56

When I\'m going to tag a commit, I need to know what changed since the last tagged commit. Eg:

a87a6sdf87a6d4 Some new feature
a87a6sdf87a6d3 Some bug fix
a87a6s         


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-29 22:22

    git log ..HEAD ?

    If you want them like in your example, on the one line with commit id + message, then

    git log ..HEAD --oneline

    and in case you don't know your latest tag or want this to be dynamic, on windows you could do

    for /f "delims=" %a in ('git describe --tags --abbrev^=0') do @set latesttag=%a
    git log %latesttag%..HEAD --oneline
    

    and on linux / git bash / windows bash

    git log $(git describe --tags --abbrev=0)..HEAD --oneline
    

    Also, if you have a case where you know a tag in history and want to print everything from that tag up to current situation, you might want to add also --decorate so it would print out any tags in between.

提交回复
热议问题