Skip to content

Commit 584cd26

Browse files
committed
doc: git-checkout: split up restoring files section
From user feedback: one user mentioned that "When the <tree-ish> (most often a commit) is not given" is confusing since it starts with a negative. To fix this "starts with a negative" problem, restructure so that `git checkout main file.txt` and `git checkout file.txt` are separate items, so we don't have to use a complex conditional. As a bonus, it appears that `-f` actually only applies to one of those forms, so we can include fewer options, and now the structure of the DESCRIPTION matches the SYNOPSIS. Signed-off-by: Julia Evans <[email protected]>
1 parent 6cfb9d4 commit 584cd26

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

Documentation/git-checkout.adoc

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ git checkout [-q] [-f] [-m] [<branch>]
1212
git checkout [-q] [-f] [-m] --detach [<branch>]
1313
git checkout [-q] [-f] [-m] [--detach] <commit>
1414
git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new-branch>] [<start-point>]
15-
git checkout [-f] <tree-ish> [--] <pathspec>...
16-
git checkout [-f] <tree-ish> --pathspec-from-file=<file> [--pathspec-file-nul]
15+
git checkout <tree-ish> [--] <pathspec>...
16+
git checkout <tree-ish> --pathspec-from-file=<file> [--pathspec-file-nul]
1717
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [--] <pathspec>...
1818
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] --pathspec-from-file=<file> [--pathspec-file-nul]
1919
git checkout (-p|--patch) [<tree-ish>] [--] [<pathspec>...]
@@ -71,14 +71,17 @@ commit would overwrite your uncommitted changes.
7171
+
7272
Omitting _<branch>_ detaches `HEAD` at the tip of the current branch.
7373
74-
`git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <pathspec>...`::
75-
`git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] --pathspec-from-file=<file> [--pathspec-file-nul]`::
74+
`git checkout <tree-ish> [--] <pathspec>...`::
75+
`git checkout <tree-ish> --pathspec-from-file=<file> [--pathspec-file-nul]`::
7676
77-
Overwrite the contents of the files that match the pathspec.
78-
When the _<tree-ish>_ (most often a commit) is not given,
79-
overwrite working tree with the contents in the index.
80-
When the _<tree-ish>_ is given, overwrite both the index and
81-
the working tree with the contents at the _<tree-ish>_.
77+
Overwrite both the index and the working tree with the
78+
contents at the _<tree-ish>_ for the files that match the pathspec.
79+
80+
`git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [--] <pathspec>...`::
81+
`git checkout [-f|--ours|--theirs|-m|--conflict=<style>] --pathspec-from-file=<file> [--pathspec-file-nul]`::
82+
83+
Overwrite working tree with the contents in the index for the files
84+
that match the pathspec.
8285
+
8386
The index may contain unmerged entries because of a previous failed merge.
8487
By default, if you try to check out such an entry from the index, the
@@ -89,7 +92,7 @@ using `--ours` or `--theirs`. With `-m`, changes made to the working tree
8992
file can be discarded to re-create the original conflicted merge result.
9093
9194
`git checkout (-p|--patch) [<tree-ish>] [--] [<pathspec>...]`::
92-
This is similar to the previous mode, but lets you use the
95+
This is similar to the previous two modes, but lets you use the
9396
interactive interface to show the "diff" output and choose which
9497
hunks to use in the result. See below for the description of
9598
`--patch` option.

0 commit comments

Comments
 (0)