GitFlow 中剪切发布分支的实际命令

sme*_*eeb 5 git github git-flow

git 新手,正在尝试学习 GitFlow。使用 GitFlow,您经常会从develop分支上切下一个发布分支,以便您可以隔离新更改的子集并将它们部署到某个临时/非生产环境。但我实际上找不到可靠的文档来说明剪切这些发布分支的正确过程(命令方面)。是吗:

git checkout develop
git pull
git checkout -b release/1.1.3
git add .
git commit -m "Cutting release branch for v1.1.3."
git push
Run Code Online (Sandbox Code Playgroud)

或者是:

git checkout develop
git pull
git checkout -b release/1.1.3
git push origin release/1.1.3
Run Code Online (Sandbox Code Playgroud)

或者是别的什么?为什么?!

lar*_*sks 7

首先要确保您正在开发分支并且它是最新的:

 git checkout develop
 git pull
Run Code Online (Sandbox Code Playgroud)

如果你运行:

git checkout -b release/1.1.3
git push
Run Code Online (Sandbox Code Playgroud)

您可能会收到以下错误:

fatal: The current branch release/1.1.3 has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin release/1.1.3
Run Code Online (Sandbox Code Playgroud)

因为您已经在本地创建了一个新分支,所以它没有关联的上游跟踪分支,直到您告诉它应该跟踪什么。所以你需要明确你想把它推到哪里,比如:

git push origin release/1.1.3
Run Code Online (Sandbox Code Playgroud)