I'm trying to retrieve a list of commits since the last commit with tag production
. Given the following commits:
cd45ab Some message 7
a43fe7 Some message 6 #2.1.2
c34cf9 Some message 5
2ef4f5 Some message 4 #2.1.1
ab43ac Some message 3
63ba2c Some message 2 #2.1.0 #production
be461d Some message 1
And when using the command git log 2.1.0..HEAD --pretty=format:"%s"
, I receive a list consisting of commit messages 2 up to and including 7, which is what I expected.
However, when using git log production..HEAD --pretty=format:"%s"
, I receive an seemingly unfiltered list of commit messages including commit message 1 and hundreds of earlier commits.
As commit 2 is both tagged with 2.1.0
and production
, I would have expected to be able to use the production
tag as well. Would anyone know why this isn't working? My goal is to create a changelog of all the commits since the last commit tagged with production
.
CodePudding user response:
You spotted your first issue : your local production
tag is not up to date.
It looks like you use a moving tag to spot your production
commit. By default, most git commands will not overwrite your local tags, so a simple git fetch
will not auto update your local copy of refs/tags/production
.
You can explicitly force fetch it :
git fetch --force origin production
git fetch --force --tags # this one will force update all your local tags
you can also add a refspec to instruct git to do it on every git fetch
:
in the .git/config
, spot the section [remote "origin"]
, and add an extra line
fetch = refs/tags/production:refs/tags/production