gitgit-branchgit-tag

How to create a new branch from a tag?


I'd like to create a new master branch from an existing tag. Say I have a tag v1.0. How to create a new branch from this tag?


Solution

  • Wow, that was easier than I thought:

    git checkout -b newbranch v1.0
    

    If running the above command you get an error

    warning: refname 'v1.0' is ambiguous.
    fatal: ambiguous object name: 'v1.0'

    this is because you also have a branch with name v1.0. In this case specify tags/ prefix:

    git checkout -b newbranch tags/v1.0