“git branch”与“git branch”之间的区别是什么?和“git checkout -b”? [英] What is the difference between "git branch" and "git checkout -b"?

查看:618
本文介绍了“git branch”与“git branch”之间的区别是什么?和“git checkout -b”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 git checkout -b 来创建一个新分支。我认为 git branch 可以做同样的事情。
如果这两个命令有所不同,如果它们完全不同?

解决方案

git checkout -b BRANCH_NAME 会创建一个新的分支并检出新的分支,而 git分支BRANCH_NAME 会创建一个新分支,但会将您留在同一分支上。 / p>

换句话说, git checkout -b BRANCH_NAME 会为您做以下工作。

  git分支BRANCH_NAME#创建一个新分支
git checkout BRANCH_NAME#然后切换到新分支


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 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.

In other words git checkout -b BRANCH_NAME does the following for you.

git branch BRANCH_NAME    # create a new branch
git checkout BRANCH_NAME  # then switch to the new branch

这篇关于“git branch”与“git branch”之间的区别是什么?和“git checkout -b”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆