[英]GIT : All new branches come under previous branch
我是git的新手,所以这是我的仓库https://github.com/nayak94/nayak-kernel正在分支0.1上工作,现在想尝试一些新功能,因此使用“ git checkout -b 0.2”将分支0.2做成了现在它显示https://github.com/nayak94/nayak-kernel/branches 0.2与0.1合并了有人可以解释它是如何工作的,通读许多教程无法理解,如何在不合并的情况下创建新分支旧的吗?
When you create a new branch, git forks the new branch from the current branch you are on, in your case, it is 0.1
. 当您创建一个新分支时,git从您当前所在的分支中派生出新分支,在本例中为
0.1
。
If you want to create branch from master
, you should switch to master and create branch from there. 如果要从
master
创建分支,则应切换到master并从那里创建分支。
git checkout master
git checkout -b 0.2
After that you have two branches ( 0.1
and 0.2
) created from master
branch. 之后,您将从
master
分支创建了两个分支( 0.1
和0.2
)。
As a side note: git checkout -b branch_name
creates a branch and switches to that branch. 附带说明:
git checkout -b branch_name
创建一个分支并切换到该分支。 Meanwhile git branch branch_name
creates a branch but stays on the current branch. 同时,
git branch branch_name
创建一个分支,但保留在当前分支上。 If you have used the second option, you shouldn't have had this problem. 如果您使用了第二个选项,那么您应该不会遇到这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.