Documentation/checkout: clarify description

To the first-time reader, it may not be obvious that ‘git checkout’
has two modes, nor that if no branch is specified it will read
from the index.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Jonathan Nieder 2010-05-30 03:41:53 -05:00 committed by Junio C Hamano
parent 371276bf29
commit c5b41519c7
1 changed files with 17 additions and 11 deletions

View File

@ -15,17 +15,23 @@ SYNOPSIS


DESCRIPTION DESCRIPTION
----------- -----------
Retrieves files from the index or specified tree and writes them
to the working tree.

'git checkout' [-b <new branch>] [<branch>]::


When <paths> are not given, this command switches branches by When <paths> are not given, this command switches branches by
updating the index, working tree, and HEAD to reflect the specified updating the index, working tree, and HEAD to reflect the
branch. specified branch.

+
If `-b` is given, a new branch is created and checked out, as if If `-b` is given, a new branch is created and checked out, as if
linkgit:git-branch[1] were called; in this case you can linkgit:git-branch[1] were called; in this case you can
use the --track or --no-track options, which will be passed to `git use the --track or --no-track options, which will be passed to `git
branch`. As a convenience, --track without `-b` implies branch branch`. As a convenience, --track without `-b` implies branch
creation; see the description of --track below. creation; see the description of --track below.


'git checkout' [--patch] [<tree-ish>] [--] [<pathspec>...]::

When <paths> or --patch are given, this command does *not* switch When <paths> or --patch are given, this command does *not* switch
branches. It updates the named paths in the working tree from branches. It updates the named paths in the working tree from
the index file, or from a named <tree-ish> (most often a commit). In the index file, or from a named <tree-ish> (most often a commit). In
@ -34,7 +40,7 @@ either of them results in an error. The <tree-ish> argument can be
used to specify a specific tree-ish (i.e. commit, tag or tree) used to specify a specific tree-ish (i.e. commit, tag or tree)
to update the index for the given paths before updating the to update the index for the given paths before updating the
working tree. working tree.

+
The index may contain unmerged entries after a failed merge. By The index may contain unmerged entries after a failed merge. By
default, if you try to check out such an entry from the index, the default, if you try to check out such an entry from the index, the
checkout operation will fail and nothing will be checked out. checkout operation will fail and nothing will be checked out.