I am a bit confused about git tagging even after reading the documentation.
Say I am making changes to my develop
branch.
Should I create a tag before making changes, or should I add my tag after making my changes? Which workflow is better?
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'
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
How are tags different from branches? And which is better?
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.
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.
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.
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] .
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
):
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 theDevelop
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 can be renamed or deleted easily.
(Annotated) Tags cannot be modified without affecting the history of the git repo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With