17

I have successfully made, committed, and pushed changes to a central git repository. I realize now that I want to tag the current version of all files. So I do:

git tag -a 0.5

That succeeds. But now I try a git push and I am told there's nothing to commit. How do I push my new tag to the central repository?

(Note that git tag shows the tag 0.5, but only locally)

Stevoisiak
  • 23,794
  • 27
  • 122
  • 225
ChrisInEdmonton
  • 4,470
  • 5
  • 33
  • 48
  • 1
    Possible duplicate of [Do git tags get pushed as well?](http://stackoverflow.com/questions/2988088/do-git-tags-get-pushed-as-well) – Stevoisiak Apr 19 '17 at 04:20

2 Answers2

26

I think you want

git push --tags

as that, well, pushes all your tags :)

There are some alternatives of course, this being git and all (replace origin with your repo of choice):

git push origin tag 0.5

or

git push origin refs/tags/0.5:refs/tags/0.5

See git-push(1) for further details. "git ready" has some useful info in their tagging article as well.

Henrik Gustafsson
  • 51,180
  • 9
  • 47
  • 60
  • 1
    **Addendum:** if you create new commits on your branch, and then push (so there is something to transfer), git should detect all new tags that point to commits that are present after push on remote side, and push them too. – Jakub Narębski Apr 25 '09 at 16:15
  • 2
    Default config git repos do not push tags that happen to exist on commits. Tags are only pushed if explicitly named or --tags used. – Vincent Scheib Jul 26 '11 at 23:04
4

Since git 1.8.3 (April 22d, 2013), try a:

git push --follow-tags

When you push new commits, any tag referenced by those commits would be pushed as well.
In your case, any tag referenced by a commit already pushed should be pushed too.

That allows you to always use one command when pushing commits and tags.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250