How to create a new branch from a tag?

后端 未结 7 2159
不思量自难忘°
不思量自难忘° 2020-12-12 08:56

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?

7条回答
  •  暖寄归人
    2020-12-12 09:17

    The situation becomes a little bit problematic if we want to create a branch from a tag with the same name.

    In this, and in similar scenarios, the important thing is to know: branches and tags are actually single-line text files in .git/refs directory, and we can reference them explicitly using their pathes below .git. Branches are called here "heads", to make our life more simple.

    Thus, refs/heads/master is the real, explicit name of the master branch. And refs/tags/cica is the exact name of the tag named cica.

    The correct command to create a branch named cica from the tag named cica is:

    git branch cica refs/tags/cica
    

提交回复
热议问题