1

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
Alok
  • 8,452
  • 13
  • 55
  • 93

2 Answers2

2

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?

Krzysztof Woliński
  • 328
  • 1
  • 2
  • 12
  • Nope, it shows me the previous commit, when I do `git show ` – Alok Jul 22 '20 at 08:14
  • Try removing the tag you've created (`git tag -d `) and then tagging again ("Have you tried switching it off and on again?"). This time the tag will be pointing to your HEAD which is what you want. If you get an error when pushing the tag to origin, you can remove it there first (`git push --delete origin `) – Krzysztof Woliński Jul 22 '20 at 08:36
2

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>
LeGEC
  • 46,477
  • 5
  • 57
  • 104