Why is the git command to switch branches named git checkout
?
Does it really make sense ?
I would name it git switch
instead. Besides, git checkout
has other meanings: e.g. reverting a file (like svn revert
)
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:
git checkout
does two very distinct things, and it would be helpful for newcomers if they were separate commands.
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" :)
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.
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...
Update: VonC links in the comments to an answer with a neat alias to make git checkout
safer in either of its two usages ;)