git switch和git checkout< branch>有什么区别? [英] What's the difference between git switch and git checkout <branch>
问题描述
Git 2.23 引入新命令 git switch
-阅读文档后,似乎与 git checkout< branchname>
几乎一样,有人可以解释其中的区别或用例吗?
Git 2.23 introduces a new command git switch
-- after reading the docs, it seems pretty much the same as git checkout <branchname>
can someone explain the difference or use case?
引入了两个新命令"git switch"和"git restore"拆分签出分支机构以推进其历史"从索引和/或树状结构中检查出要处理的路径单次"git checkout"中的前进当前历史记录"命令.
Two new commands "git switch" and "git restore" are introduced to split "checking out a branch to work on advancing its history" and "checking out paths out of the index and/or a tree-ish to work on advancing the current history" out of the single "git checkout" command.
推荐答案
好吧,根据您链接到的文档,其唯一目的是拆分并阐明 git checkout
的两种不同用法:
Well, according to the documentation you link to, its sole purpose is to split and clarify the two different uses of git checkout
:
-
git switch
现在可以用来更改分支,就像git checkout< branchname>
一样 -
git restore
可以用于将文件重置为某些版本,就像git checkout-< path_to_file>
一样
git switch
can now be used to change branches, asgit checkout <branchname>
doesgit restore
can be used to reset files to certain revisions, asgit checkout --<path_to_file>
does
人们对使用 git checkout
的这些不同方式感到困惑,正如您从Stackoverflow上有关 git checkout
的许多问题中可以看到的那样.Git开发人员似乎已经考虑到了这一点.
People are confused by these different ways to use git checkout
, as you can see from the many questions regarding git checkout
here on Stackoverflow. Git developers seem to have taken this into account.
这篇关于git switch和git checkout< branch>有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!