Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I commit a git tag?

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)

like image 480
ChrisInEdmonton Avatar asked Apr 24 '09 22:04

ChrisInEdmonton


People also ask

What is git tag command?

Tags are ref's that point to specific points in Git history. Tagging is generally used to capture a point in history that is used for a marked version release (i.e. v1. 0.1). A tag is like a branch that doesn't change. Unlike branches, tags, after being created, have no further history of commits.

Which git command is used to give tags to the specified commit?

Let us tag the current HEAD by using the git tag command. Tom provides a tag name with -a option and provides a tag message with –m option. If you want to tag a particular commit, then use the appropriate COMMIT ID instead of the HEAD pointer.

What is the difference between tag and commit?

When it is, a commit will automatically update the master reference to point to that new commit; in other words, branches are mutable references. A tag, on the other hand, is created to point to a specific commit and thereafter does not change, even if the branch moves on. In other words, tags are immutable references.


2 Answers

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.

like image 111
Henrik Gustafsson Avatar answered Sep 17 '22 14:09

Henrik Gustafsson


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.

like image 30
VonC Avatar answered Sep 21 '22 14:09

VonC