Skip to content

Commit c5b4151

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 371276b commit c5b4151

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

Documentation/git-checkout.txt

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,32 @@ SYNOPSIS
1515

1616
DESCRIPTION
1717
-----------
18+
Retrieves files from the index or specified tree and writes them
19+
to the working tree.
1820

19-
When <paths> are not given, this command switches branches by
20-
updating the index, working tree, and HEAD to reflect the specified
21-
branch.
21+
'git checkout' [-b <new branch>] [<branch>]::
2222

23+
When <paths> are not given, this command switches branches by
24+
updating the index, working tree, and HEAD to reflect the
25+
specified branch.
26+
+
2327
If `-b` is given, a new branch is created and checked out, as if
2428
linkgit:git-branch[1] were called; in this case you can
2529
use the --track or --no-track options, which will be passed to `git
2630
branch`. As a convenience, --track without `-b` implies branch
2731
creation; see the description of --track below.
2832

29-
When <paths> or --patch are given, this command does *not* switch
30-
branches. It updates the named paths in the working tree from
31-
the index file, or from a named <tree-ish> (most often a commit). In
32-
this case, the `-b` and `--track` options are meaningless and giving
33-
either of them results in an error. The <tree-ish> argument can be
34-
used to specify a specific tree-ish (i.e. commit, tag or tree)
35-
to update the index for the given paths before updating the
36-
working tree.
33+
'git checkout' [--patch] [<tree-ish>] [--] [<pathspec>...]::
3734

35+
When <paths> or --patch are given, this command does *not* switch
36+
branches. It updates the named paths in the working tree from
37+
the index file, or from a named <tree-ish> (most often a commit). In
38+
this case, the `-b` and `--track` options are meaningless and giving
39+
either of them results in an error. The <tree-ish> argument can be
40+
used to specify a specific tree-ish (i.e. commit, tag or tree)
41+
to update the index for the given paths before updating the
42+
working tree.
43+
+
3844
The index may contain unmerged entries after a failed merge. By
3945
default, if you try to check out such an entry from the index, the
4046
checkout operation will fail and nothing will be checked out.

0 commit comments

Comments
 (0)