Get commit list between 2 last tags in git - on windows - without knowing the tags

Viewed 49

I am trying to get list of commits between the last Tag and the Tag before it

Answers that I see here ( and that I currently use ) are like this:

git log --pretty=oneline TagA...TagB

But this forces me to know the tag numbers that are not available at this part of the build process

thus sometimes this command fails, stopping the build process

Build machine is a Windows machine, I have seen unix related answers

Any way to achieve that ?

2 Answers

Get the last tag in the current branch:

lasttag=`git describe --tags --abbrev=0`

Get the previous tag before the last:

prev_tag=`git describe --tags --abbrev=0 $lasttag~`

See the log:

git log $prev_tag..$lasttag

What I ended up doing on windows after looking on the first answer:

it describe --tags --abbrev=0 > tmpFile 
set /P lasttag= < tmpFile 
del tmpFile 

git describe --tags --abbrev=0 %lasttag%~ > tmpFile2
set /P prev_tag= < tmpFile2 
del tmpFile2

git log %prev_tag%...%lasttag% >ReleaseNotes.txt
Related