本文翻译自:How to create a new branch from a tag?
I'd like to create a new master branch from an existing tag. 我想从现有标签创建一个新的master分支。 Say I have a tag v1.0
. 说我有一个标签v1.0
。 How to create a new branch from this tag? 如何从这个标签创建一个新的分支?
#1楼
参考:https://stackoom.com/question/juFR/如何从标签创建新分支
#2楼
哇,这比我想象的要容易:
git checkout -b newbranch v1.0
#3楼
如果您只是想创建一个新分支而不立即更改它,则可以执行以下操作:
git branch newbranch v1.0
#4楼
My branch list (only master now) 我的分支机构列表(现在仅适用于母版 )
My tag list (have three tags) 我的标签列表(具有三个标签)
Switch to new branch feature/codec from opus_codec tag 从opus_codec标签切换到新的分支功能/编解码器
git checkout -b feature/codec opus_codec
#5楼
I have resolve the problem as below 1. Get the tag from your branch 2. Write below command 我已经解决了以下问题1.从您的分支机构获取标签2.写以下命令
Example: git branch <Hotfix branch> <TAG>
git branch hotfix_4.4.3 v4.4.3
git checkout hotfix_4.4.3
or you can do with other command 或者你可以用其他命令
git checkout -b <Hotfix branch> <TAG>
-b stands for creating new branch to local
once you ready with your hotfix branch, It's time to move that branch to github, you can do so by writing below command 一旦准备好您的hotfix分支,是时候将该分支移至github了,可以通过编写以下命令来实现
git push --set-upstream origin hotfix_4.4.3
#6楼
I used the following steps to create a new hot fix branch from a Tag. 我使用以下步骤从标签创建新的热修复分支。
Syntax 句法
git checkout -b <New Branch Name> <TAG Name>
Steps to do it. 步骤去做。
- git checkout -b NewBranchName v1.0 git checkout -b NewBranchName v1.0
- Make changes to pom / release versions 更改pom /发布版本
- Stage changes 阶段变更
- git commit -m "Update pom versions for Hotfix branch" git commit -m“为修补程序分支更新pom版本”
- Finally push your newly created branch to remote repository. 最后,将您新创建的分支推送到远程存储库。
git push -u origin NewBranchName
I hope this would help. 我希望这会有所帮助。