Tuesday, August 20, 2019 [Tweets] [Favorites]

Git 2.23

Taylor Blau:

It turns out git checkoutcan do quite a lot. You can use it to change branches with git checkout <branch> or if you supply --branch, create a new branch (as in git checkout --branch <new-branch>). If you don’t want to switch branches, don’t worry, because git checkout can change individual files, too. If you write git 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 with git checkout [treeish] -- <filename>.

The new commands, by contrast, aim to clearly separate the responsibilities of git checkout into two narrower categories: operations which change branches and operations which change files. To that end, git switch takes care of the former, and git restore the latter.

See also: Junio C Hamano.

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment