0

I have a list of tags in my project, listed e.g. as follows:

(develop)$ git tag
v2.0.0
v2.0.1

I am able to find the branch that the first tag belongs to, but not so for the second one;

/home/pkaramol/Workspace/gitlab/myproject
(develop)$ git branch --contains tags/v2.0.0
* develop
/home/pkaramol/Workspace/gitlab/myproject
(develop)$ git branch --contains tags/v2.0.1

How is it possible that a tag exists but does not belong to a branch?

Mureinik
  • 297,002
  • 52
  • 306
  • 350
pkaramol
  • 16,451
  • 43
  • 149
  • 324

2 Answers2

1

Tags are just names associated with commits. Branches are essentially names associated with commits that have a special treatment that moves the name to point to a new commit if you create a new commit on that branch.

There's no requirement that a tag "belong" to a branch or vise-versa.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
0

I just needed the -a flag to include remote refs in my query:

(develop)$ git branch -a --contains tags/v2.0.1
  remotes/origin/stable/v2.0
pkaramol
  • 16,451
  • 43
  • 149
  • 324