[英]What is the git command to create a branch based on the upstream master?
When I've made some commits to my local master branch, but not pushed them. 当我对本地master分支进行了一些提交之后,却没有推送它们。 And then I want to create another branch before I push those commits, but the other branch should not include those commits in its history, but rather be based on the clean upstream master. 然后,我想在推送这些提交之前创建另一个分支,但是另一个分支不应在其历史记录中包含这些提交,而应基于干净的上游主服务器。
git checkout -b <new branch name> origin/master
You can checkout the upstream master with git checkout origin/master
and then create a branch via git branch <branchname>
您可以使用git checkout origin/master
检出上游主服务器,然后通过git branch <branchname>
创建分支
You would also be able to checkout a specific SHA on your local and create a branch there with git checkout -b <branchname> <SHA of commit>
. 您还可以在本地签出特定的SHA并在其中使用git checkout -b <branchname> <SHA of commit>
创建分支。 This is useful if you decide that you also need to have one of the commits that you made on the new branch. 如果您决定还需要在新分支上进行的提交之一,这将很有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.