Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tag multiple branches in git?

I have a git repository with two branches; one for code that's used for manufacturing/test and one that's the actual production firmware (they're nearly identical). It's now time to cut a release to send to the manufacturer, so I naturally want to put down some appropriate tags on both branches.

But, it seems that git won't let me put the same tag name on both branches. If I try to tag the branches individually it tells me the tag already exists when I go to tag the seconds branch. I tried passing two commits to git tag, but it didn't like that either. I don't necessarily need to always tag the two branches in lockstep, but I don't want to add random characters to the tags just to avoid name collisions.

Is there some way to do what I want, or am I wanting to do the wrong thing?


One branch is the code that manufacturing puts on the device to test that it was assembled properly. The other branch is the code that ships in the product. It's not really two branches per release. This is the first release for this product, and therefore first release for both branches, so I tried to tag both branches with 'release-1.0'.

like image 349
Brandon Fosdick Avatar asked Jun 09 '09 22:06

Brandon Fosdick


People also ask

Can a git branch have multiple tags?

Git allows the creation of multiple tags on a branch or different branches. There exist two different types of git tags which are lightweight tags and the annotated git tags. The main distinction between these two tags is the amount of information or metadata they store.

Does git tag apply to all branches?

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.

Can a commit have multiple tags?

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).


1 Answers

You're wanting to do the wrong thing. The purpose of a tag is to unambiguously identify a particular revision. If I were you, I'd tag only the production branch and leave the testing branch untagged.

However, it's pretty weird that you've got two independent branches per release. Why is this? The answer might help to describe a better solution.


Since the tags aren't really supposed to point to the same revision, but (potentially) different revisions, the tags should be something like this:

  • appname-1.0-manufacturing
  • appname-1.0-production

That way, you will know which release each tag belongs to, as well as where the code ended up.

like image 75
John Millikin Avatar answered Oct 16 '22 23:10

John Millikin