Git tag before or after merge?

user1699176 picture user1699176 · Sep 26, 2012 · Viewed 26.4k times · Source

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.

Answer

Amber picture Amber · Sep 26, 2012

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.