I'm currently trying to tag a git projects which same version tag for a release. The project is an extension for an exist product. For backward compatibility with the existing product, we needed to created two different versions of our project. So we created two branches named master (latest version of product) and productX.X (backward compatibility to product version X.X) which contain the different version releases of our product. We're merging the code from the branch master to the branch productX.X to keep the code in sync.
The number of branches will grow as we need to great a new version of our project when a new version of the product will be released.
Now, I want to release version 1.0.0 of our project for both product versions (latest and X.X). I read that I can use only once tag name for all branches. Is really not possible to tag different branches with the same tag "1.0.0"?
If it isn't possible what would be the good approach?
Alternative approach: Tag the branch "productversionX.X" with a postfix: master: 1.0.0 productversionX.X: 1.0.0-productX.X
I'm currently using Tower as git client and gitlab as git server.
Thanks Patrick
You should never name a tag and a branch the same name! It makes sense in a case like this to use naming conventions on the tags to keep from colliding on the branch names. Versus when we releasing code from the master branch. You can find the common parent in git using merge-base to do a Tag on code from the past.
It is important to understand that tags have no direct relationship with branches - they only ever identify a commit. That commit can be pointed to from any number of branches - i.e., it can be part of the history of any number of branches - including none.
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.
We occasionally have two tags on the same commit. When we use git describe for that commit, git describe always returns the first tag. My reading of the git-describe man page seems to indicate that the second tag should be returned (which makes more sense).
A Git tag points to exactly one commit, i.e. there's no such thing as per-branch tags. If you have different variants of the same base version (for example 1.0.0), using a special prefix or suffix as you suggested is a reasonable solution.
Depending on what type of differences there are between the branches it may make more sense to use static or dynamic configuration in the code to select between different behaviors. That would allow you to produce all variants of the product from a single commit and hence use the same tag for them all.
You can't.
tags are just nice names for the ugly git hashes. So a tag
to a <commit-id>
.
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