Skip to content

Commit 12575b7

Browse files
committed
Merge branch 'jn/checkout-doc' into maint
* jn/checkout-doc: Documentation/checkout: clarify description Documentation/checkout: clarify description
2 parents 3c65689 + b831ded commit 12575b7

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

Documentation/git-checkout.txt

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,41 @@ SYNOPSIS
1515

1616
DESCRIPTION
1717
-----------
18-
19-
When <paths> are not given, this command switches branches by
20-
updating the index, working tree, and HEAD to reflect the specified
18+
Updates files in the working tree to match the version in the index
19+
or the specified tree. If no paths are given, 'git checkout' will
20+
also update `HEAD` to set the specified branch as the current
2121
branch.
2222

23-
If `-b` is given, a new branch is created and checked out, as if
24-
linkgit:git-branch[1] were called; in this case you can
25-
use the --track or --no-track options, which will be passed to `git
26-
branch`. As a convenience, --track without `-b` implies branch
27-
creation; see the description of --track below.
28-
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.
37-
38-
The index may contain unmerged entries after a failed merge. By
39-
default, if you try to check out such an entry from the index, the
23+
'git checkout' [<branch>]::
24+
'git checkout' -b <new branch> [<start point>]::
25+
26+
This form switches branches by updating the index, working
27+
tree, and HEAD to reflect the specified branch.
28+
+
29+
If `-b` is given, a new branch is created as if linkgit:git-branch[1]
30+
were called and then checked out; in this case you can
31+
use the `--track` or `--no-track` options, which will be passed to
32+
'git branch'. As a convenience, `--track` without `-b` implies branch
33+
creation; see the description of `--track` below.
34+
35+
'git checkout' [--patch] [<tree-ish>] [--] <pathspec>...::
36+
37+
When <paths> or `--patch` are given, 'git checkout' *not* switch
38+
branches. It updates the named paths in the working tree from
39+
the index file or from a named <tree-ish> (most often a commit). In
40+
this case, the `-b` and `--track` options are meaningless and giving
41+
either of them results in an error. The <tree-ish> argument can be
42+
used to specify a specific tree-ish (i.e. commit, tag or tree)
43+
to update the index for the given paths before updating the
44+
working tree.
45+
+
46+
The index may contain unmerged entries because of a previous failed merge.
47+
By default, if you try to check out such an entry from the index, the
4048
checkout operation will fail and nothing will be checked out.
41-
Using -f will ignore these unmerged entries. The contents from a
49+
Using `-f` will ignore these unmerged entries. The contents from a
4250
specific side of the merge can be checked out of the index by
43-
using --ours or --theirs. With -m, changes made to the working tree
44-
file can be discarded to recreate the original conflicted merge result.
51+
using `--ours` or `--theirs`. With `-m`, changes made to the working tree
52+
file can be discarded to re-create the original conflicted merge result.
4553

4654
OPTIONS
4755
-------

0 commit comments

Comments
 (0)