3 ms·
> There is just a convenience operation on `git checkout` that also changes branches. Isn't that violating 'doing one thing'? (Your other examples in this poin
by ajanuary 14y ago
> There is just a convenience operation on `git checkout` that also changes branches.
Isn't that violating 'doing one thing'? (Your other examples in this point are valid, and serve to show how powerful building concepts on top of a few primitives can be, if confusing at times)
- the_mitsuhiko 14y ago> Isn't that violating 'doing one thing'? Yes. But that violation would also be there if `git branch` would checkout. And in that sense, what's more odd "git checkout -b new-branch" or "git branch --checkout new-branch"?
- nazri1 14y agoHere's how I view the checkout command: It is used to check out stuff from your git database into your working tree. Stuff here means either the whole tree or some files in it. You can check out a whole tree (branch) by specifying its sha1, or you can check out a single file by specifying the tree and the filename. The fact that checkout can be used to create a branch is just a convenience because most of the time it's easier to give the tree sha1 a name to refer to for further git commands.
- Aga 14y agoThis is exactly what I tell students in my Git courses during the first hour. Git checkout is a command to read something from your .git-folder to your working directory. Especially for people coming from ClearCase, the concept of Git checkout needs to be clarified as fast as possible. (In CC checkout means you make an element (file) editable for you, and possibly reserve it to you too)