Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git tagging questions

I am a bit confused about git tagging even after reading the documentation.

Say I am making changes to my develop branch.

  1. Should I create a tag before making changes, or should I add my tag after making my changes? Which workflow is better?

  2. Initially I was ask to just use git push --tags, but after running git tag I was shown a list of 5 tags (release-1, ..., release-5 ), when I tried running git tag -v release-5 I was prompted with the following errors, the same applies for other releases. Any ideas?

    error: 575bbe56b0c021c51e2b819763c1ff15cc5d2186: cannot verify a non-tag object of type commit.
    error: could not verify the tag 'release-5'
    
  3. If I have used git push to push tags in the Develop branch, followed by a merge to the Master branch, do I still need to do another round of git push --tags

  4. How are tags different from branches? And which is better?

like image 688
dissidia Avatar asked Jul 03 '14 05:07

dissidia


People also ask

What is tagging used for in git?

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.

How do I tag something in git?

Create Git Tag. In order to create a new tag, you have to use the “git tag” command and specify the tag name that you want to create. As an example, let's say that you want to create a new tag on the latest commit of your master branch. To achieve that, execute the “git tag” command and specify the tagname.

Does git tag apply to all branches?

Yes! The difference between a branch name and a tag name is that a branch name is expected to move, and git will move it automatically in that "on a branch" case.

Do I tag before or after commit?

You can tag a revision right after your commit or later (after a push). Then, you can push your tag with: git push origin [tagname] .


1 Answers

Should I create a tag first before I do any changes though I know that I can tag it after the changes. Which workflow is better?

You don't have to, but it can help if you want to go back to an identified point.

You need to be aware of two kinds of tags though (as mentioned in git tag):

  • lightweight tags (reference for the SHA-1 object name of the commit object)
  • annotated tags (independent tag object, including a creation date, the tagger name and e-mail, a tagging message, and an optional GnuPG signature): git tag -a myTag or git tag -m "new myTag" myTag both created annotated tags.
    git tag myTag creates a lightweight tag only.

Annotated tags are meant for release while lightweight tags are meant for private or temporary object labels.

cannot verify a non-tag object of type commit.

You can only verify an annotated tags, since it is an independent object which can support an optional gpg signature (that is the signature you are trying to verify with the -v option).
A lightweight tag is just a shortcut to a commit.

git push --tags in the Develop branch:

That is an operation which will impact your remote upstream repo.
And it will push all tags, not just the ones set in the Develop branch.
To push only the ones that matters, I recommend git push --follow-tags

followed by a merge to the Master branch,

That is a local operation done in your local repo, and has nothing to do with the git push just done before.

do I still need to do another round of git push --tags

Both operations are completely unrelated.

How different are the tags different from branches? And which is better?

As opposed to SVN, tags are very different from branches and complement them: one isn't better than the other.

  • branches are for isolating a development effort (see "When should you branch?").
  • tags are for identifying specific points in history as being important (for instance, for marking releases).

Branches can be renamed or deleted easily.
(Annotated) Tags cannot be modified without affecting the history of the git repo.

like image 75
VonC Avatar answered Nov 14 '22 20:11

VonC