&"git branch&"之间有什么区别?和"git checkout -b&"? [英] What is the difference between "git branch" and "git checkout -b"?
本文介绍了&"git branch&"之间有什么区别?和"git checkout -b&"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用了 git checkout -b
创建了一个新分支.我认为 git branch
做同样的事情.如果这两个命令完全不同,这两个命令又有什么不同?
I used git checkout -b
to create a new branch. I think that git branch
does the same thing.
How do these two commands differ, if they differ at all?
推荐答案
git checkout -b BRANCH_NAME
创建一个新分支并签出新分支,而 git branch BRANCH_NAME
创建一个新分支,但将您留在同一分支上.
git checkout -b BRANCH_NAME
creates a new branch and checks out the new branch while git branch BRANCH_NAME
creates a new branch but leaves you on the same branch.
换句话说, git checkout -b BRANCH_NAME
为您执行以下操作.
In other words git checkout -b BRANCH_NAME
does the following for you.
git branch BRANCH_NAME # create a new branch
git switch BRANCH_NAME # then switch to the new branch
这篇关于&"git branch&"之间有什么区别?和"git checkout -b&"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文