3 ms·
git checkout puts files from the repository into your working directory. For convenience, it will also update the HEAD ref if you check out the full contents of
by chousuke 7y ago
git checkout puts files from the repository into your working directory. For convenience, it will also update the HEAD ref if you check out the full contents of a branch.
I'm not sure what's so confusing about it. Are people thinking of their entire git workdir as the repository? I suppose the fact that .git is often in the same directory as the checkout might lead to people not thinking of them as separate entities.
- lilyball 7y ago> For convenience, it will also update the HEAD ref if you check out the full contents of a branch. Not quite accurate. From the root of the repo, `git checkout foo -- .` will checkout the entire contents of the branch without updating HEAD.
- comex 7y ago> For convenience, it will also update the HEAD ref if you check out the full contents of a branch. And updates the index. And sometimes it gets files from the index instead of a commit. From a workflow perspective, "switch to working on a different branch", "copy some files into the working tree from a different commit", and "resolve all merge conflicts in this file in favor of 'ours' or 'theirs'" are three very different operations. From a low-level perspective they're somewhat similar, but not the same.