Alok
Alok

Reputation: 9008

Git push origin <tagname> doesn't reflect the latest push

I know that there is a lot of content available for this, but none of them gave me what I desired the most.

I wanted to push my latest commit to the newly created tag on my Git Repo. I referred this:

Now, after reading, I knew that, that what I need is git push origin <tagname>. Before that, I did

$ git <tagname>
$ git show <tagname>

Both of them showed me the correct result, which gave me a green signal to go and implement the final command.

$ git add .
$ git commit -am "My message"
$ git push origin <tagname> 

Now, when I did git push origin <tagname>, I got this Everything up-to-date. I saw my GIT Repo, and nothing was pushed. After looking at some of the answers, I finally found something which worked for me partially, that is

$ git push origin : <tagname>

This indeed pushed my data to the repo, but when I checked my Tag, it did not reflect in it, it showed my the last commit only, not the current one, which I pushed just now. How can I do that, so that I can achieve pushing my data to a particular tag successfully?

Upvotes: 1

Views: 1159

Answers (2)

LeGEC
LeGEC

Reputation: 52006

A tag does not get updated with actions such as git commit.

Taking the steps from your question and numbering them :

1. git tag <tagname>
2. git show <tagname>
3. git add .
4. git commit -am "My message"
5. git push origin <tagname>

The commit at step 4. have moved your active branch, it hasn't updated the tag created at step 1..

If you typed git show <tagname> again, the tag would still be at its starting place.


If you want to update the tag locally, you have to run :

git tag --force <tagname>

If you want to additionally push that tag to origin :

git push origin --force <tagname>

Upvotes: 2

Krzysztof Woliński
Krzysztof Woliński

Reputation: 406

It seems like you tagged not the commit you wanted to tag, but the previous one - first you created a tag and then committed new changes. Does the git show <tagname> show the correct commit?

Upvotes: 2

Related Questions