[英]Commit then checkout another branch in git carries old commit?
If I am on branch b-one
and I run git commit -m "init commit"
and then git checkout -b b-two
, does the commit carry to the new branch? 如果我在分支
b-one
并且运行git commit -m "init commit"
,然后运行git checkout -b b-two
,那么提交是否可以携带到新分支上? More generally, are commits branch specific? 更一般地说,提交分支是特定的吗? Or when you commit, are you just committing on your local machine and can access that commit from any branch?
或者,当您提交时,您是否只是在本地计算机上提交并且可以从任何分支访问该提交?
The git checkout command lets you navigate between the branches created by git branch.
git checkout命令使您可以在git branch创建的分支之间导航。 Checking out a branch updates the files in the working directory to match the version stored in that branch, and it tells Git to record all new commits on that branch.
检出一个分支会更新工作目录中的文件,以匹配该分支中存储的版本,并告诉Git记录该分支上的所有新提交。 Think of it as a way to select which line of development you're working on.
可以将其视为选择您正在开发的开发路线的一种方式。
It is more interesting when you switch branch with un-committed changes: Please read http://www.gitguys.com/topics/switching-branches-without-committing/ 当您切换具有未提交的更改的分支时,它会更有趣:请阅读http://www.gitguys.com/topics/switching-branches-without-committing/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.