24

I want to create a single tag for multiple commits(merged branches).

Can we group multiple commits to a single tag , please help me on this.

7
  • 8
    No. A given tag can only point to one commit. Are you sure you're familiar enough with the concept of a tag? If not, see git-scm.com/book/en/v2/Git-Basics-Tagging
    – jub0bs
    Apr 6, 2015 at 14:03
  • Jubobs is correct. You might want to explain in more detail what you want, which should make it easier for someone to explain why a multi-commit tag is neither possible nor necessary.
    – chepner
    Apr 6, 2015 at 19:24
  • For a particular releases we do multiple commits. So how to create a tag for this type of releases ?
    – Hare Ram
    Apr 7, 2015 at 8:37
  • Multiple commits for a single release in a single Git repository? That doesn't seem to make a lot of sense, but the answer is still that a tag is connected to exactly one commit. Apr 8, 2015 at 5:46
  • 4
    @HareRam For a particular releases we do multiple commits. Why not create one tag pointing to the "most recent" of those commits? That would make more sense than creating multiple tags for a given release.
    – jub0bs
    Apr 8, 2015 at 17:51

3 Answers 3

14

What you are trying to do is not possible. A tag, like a branch, can only point to at most one commit.

1
  • 1
    I used git tag -a V2.0 - m "My Message" <commit-id> , it added my head and this passed commit-id in this tag. Can you please explain ? Jul 31, 2015 at 9:44
4

A really late answer, but you could make tags like

v1.2_b7_p0
v1.2_b7_p1
v1.2_b7_p2
v1.2_b7_p3

where the last _pX part makes them unique, but you can group by the other part. Possibly:

v1.2_b7_code
v1.2_b7_docs
v1.2_b7_demo
v1.2_b7_changelog

would work, depending on why you need so many.

But it does seem a release should be a single commit. Maybe a branch is really what you want.

2

we can add tag only one commit id git add tag -a v1.0 [commit ID]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.