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.
Tags are not merged, commits (tagged or not) are.
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.
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.
You can't merge into a specific commit so you'd need to move the tag to the commit you want.
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.
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