为什么git命令切换名为"git checkout"的分支? [英] Why is the git command to switch branches named "git checkout"?

查看:163
本文介绍了为什么git命令切换名为"git checkout"的分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么git命令切换名为git checkout的分支?
真的有意义吗?

Why is the git command to switch branches named git checkout?
Does it really make sense ?

我将其命名为git switch.此外,git checkout还有其他含义:还原文件(如svn revert)

I would name it git switch instead. Besides, git checkout has other meanings: e.g. reverting a file (like svn revert)

推荐答案

我看到大多数其他答案都在解释git checkout的作用以及为什么"checkout"可能是描述此问题的合理方法.但是,尽管我非常喜欢git,但这确实触及了我试图帮助人们理解系统时出现的两个严重的挫败点:

I see that most other answers are explaining what git checkout does and why "checkout" might be a reasonable way to describe that. However, while I love git dearly, this does touch on two serious points of frustration that arise when I'm trying to help people to understand the system:

  1. git checkout做了两个非常不同的事情,如果新手是分开的命令,这对新手会很有帮助.

  1. git checkout does two very distinct things, and it would be helpful for newcomers if they were separate commands.

愤世嫉俗的人可能暗示,故意选择git的术语来混淆来自CVS和Subversion的人们!您提到的那个(checkout)是一个很好的例子.另一个是commit,它完全在git中是本地的,并且完全依赖于CVS/SVN中的服务器-记录"的darcs术语对于git新手来说需要较少的学习知识.我喜欢的另一个示例是您在git中看到的消息需要更新",这实际上意味着:)

A cynic might suggest that git's terminology was deliberately chosen to confuse people coming from CVS and Subversion! The one you mention (checkout) is a great example. Another is commit, which is entirely local in git and entirely dependent on the server in CVS / SVN - the darcs terminology of "record" would have required less un-learning for people new to git. The other example I like is the message "needs update" that you see in git, which really means "needs to be committed" :)

当然,人们总是可以使用其他前端来进行git操作,例如 easy git iolaus 等,但是大多数人最终还是不得不学习标准命令,因此,您只需要习惯于其中一些被意外地命名即可.

Of course, one could always use a different frontend to git, such as easy git, iolaus, etc. but most people are going to have to learn the standard commands eventually anyway, so you just have to get used to some of them being named rather surprisingly.

我确定git中这些不同命令的名称是有历史原因的,但是如果选择了不同的单词,那将很有帮助...

I'm sure there are historical reasons for the names of these various commands in git, but it would have been helpful if different words had been chosen...

更新: VonC 注释中的链接到

Update: VonC links in the comments to an answer with a neat alias to make git checkout safer in either of its two usages ;)

这篇关于为什么git命令切换名为"git checkout"的分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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