Git branch from remote tag

23,766

Solution 1

You need to wrap this in two instructions

git checkout tagname && git checkout -b newbranch

Alternatively

git checkout tagname -b newbranch

Solution 2

This worked for me

$git fetch --tags
$git tag
$git checkout -b <new_branch_name> <tagname>

Solution 3

There is no concept of “remote tracking tags” like there are “remote tracking branches”. You either get the tags from the repo or you don’t. At least in the standard settings. You can change that, but I would not recommend that. Does this not work?

git checkout -b newbranch tagname
Share:
23,766
dtrunk
Author by

dtrunk

Updated on July 09, 2022

Comments

  • dtrunk
    dtrunk almost 2 years

    I've created a new local git repository mirrored from another remote repository:

    git init
    git remote add original {url}
    git pull original master
    git remote add origin {url}
    git push -u origin master
    

    This would create a mirror of originals master branch. Now I would like to create a new branch of a tag from original.

    How the commands should look like? I tried git checkout -b newbranch original/tagname but I got:

    fatal: Cannot update paths and switch to branch 'newbranch' at the same time.
    Did you intend to checkout 'original/tagname' which can not be resolved as commit?
    
  • dtrunk
    dtrunk over 11 years
    It is a remote tag, both commands didn't work (same error message as described above)
  • Chronial
    Chronial over 11 years
    do git fetch origin -t and try again.
  • jchapa
    jchapa over 11 years
    You should do git pull original tagname
  • Obaid
    Obaid over 8 years
    @dtrunk try adding the tags/ prefix to your remote tag name like this git checkout tags/<remote-tag-name> -b <new-local-branch-name>
  • powder366
    powder366 about 5 years
    And how to I track a remote tag? And can I pull from it?