'how to find which github branch tag is created from?
I am trying to find out which branch tag was created from? I have clone tag and ran following command but it return two branches. Tag can be generate from one branch I do not know why it return two branches.
Following command i have executed
- git branch -a --contains v1.0.0.0.1
it return two branches. I created tag from why it return two branches? remotes/origin/dev-genericrequest remotes/origin/release-dev
Solution 1:[1]
A tag is simply a reference to a commit, it has no relation to a branch. A commit may be part of the history of many branches, or none at all.
Consider:
- I start with an empty repo. I create hello_world.txt and commit it, which becomes the first commit to the
masterbranch. - I modify hello_world.txt file and add some text. I make another commit for that change on
master - I tag that most recent commit with the tag
hi - I create a new branch from this current state called
development. At this point, both thedevelopmentandmasterbranches contain the same commit history - I continue to make new commits to
masteranddevelopment, but thetagI added will show up for both branches, as well as any new branches that are made from a commit at or after the tagged one.
I'm sure that if you check out each branch, you'll find that the commit referenced by your tag exists in the histories of both. If you visualise it like a tree branch, the tag must have existed before the "split" between the two branches occurred.
Solution 2:[2]
git branch -a --contains v1.0.0.0.1
This command is querying all git branches containing the existing tag v1.0.0.0.1. It returns two branches because both of them contain the commit this tag points to.
From the official 'git branch' doc:
With --contains, shows only the branches that contain the named commit (in other words, the branches whose tip commits are descendants of the named commit),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | daveruinseverything |
| Solution 2 | Icyvapor |
