Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git tag before or after merge?

Tags:

git

git-tag

I have a simple question about tagging different versions of my project with git. If I just completed my 1.1 branch and plan to merge it into master, should I tag this branch as 1.1 before I merge it, or should I merge it to master and then tag it as 1.1? Would it make a difference either way? Maybe one way is preferred? Thanks.

like image 908
user1699176 Avatar asked Sep 26 '12 05:09

user1699176


People also ask

Do git tags get merged?

Tags are not merged, commits (tagged or not) are.

When should I use git tag?

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.

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] . So, yes, your sequence is ok.

Can I merge a tag to master?

You can't merge into a specific commit so you'd need to move the tag to the commit you want.


1 Answers

Depends. Will the branch fast-forward into master?

If the answer is 'yes' then it doesn't matter whether you tag it before or after doing the fast-forward merge, because the tagged commit will be the same either way.

If the answer is 'no', then you should probably tag it after merging into master (assuming you cut releases from master). In general you want your tags to match your releases (to make it easier to look at the version of the code that was released), so you tag the version in the place you're making releases from.

like image 128
Amber Avatar answered Oct 22 '22 08:10

Amber