Git 2.23
It turns out
git checkoutcan do quite a lot. You can use it to change branches withgit checkout <branch>or if you supply--branch, create a new branch (as ingit checkout --branch <new-branch>). If you don’t want to switch branches, don’t worry, becausegit checkoutcan change individual files, too. If you writegit checkout -- <filename>, you will reset<filename>in your working copy to be equivalent with what’s in your index. If you don’t want to take changes from the index, you can specify an alternative source withgit checkout [treeish] -- <filename>.The new commands, by contrast, aim to clearly separate the responsibilities of
git checkoutinto two narrower categories: operations which change branches and operations which change files. To that end,git switchtakes care of the former, andgit restorethe latter.
See also: Junio C Hamano.







