Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git create local branch for a forked upstream tag

Tags:

git

branch

fork

I've been trying to find a way to create a local branch that starts from a tag on an upstream repo I've forked and haven't found anything that helps.

I have the upstream master on a master branch locally but I'm not sure what I need to do to branch the upstream tag.

I've tried:

git branch upstream/master tagname
git branch master tagname
git branch upstream tagname

and none of those worked. Thanks.

like image 279
Ali Avatar asked Jan 05 '11 06:01

Ali


1 Answers

If the tag is fetched (your master reflects upstream/master)

git checkout -b aNewBranch aTagName

You need to make sure you have fetched the tags first.
That means git fetch upstream and then git fetch upstream --tags

If you want to fetch only one tag (instead of all tags from upstream):

git fetch upstream refs/tags/aTagName:refs/tags/aTagName

Note: with Git 2.23 (Q3 2019), that would use the new command git switch:

git switch -c aNewBranch aTagName
like image 102
VonC Avatar answered Sep 27 '22 16:09

VonC