Skip to content

Commit 3dc5951

Browse files
committed
doc: git-checkout: clarify restoring files section
- Use the term "Restore" to mirror `git restore` - Many Git users do not know what a "tree-ish" is. Clarify by using an example of each case, and by saying "commit or tree" in the text instead of "<tree-ish>" - Many Git users do not know what the "index" is. Instead say "stage the file's contents" where appropriate, since Git often uses "stage" as a verb to mean the same thing as "add to the index" and it's a more familiar term. Signed-off-by: Julia Evans <[email protected]>
1 parent 1faad2a commit 3dc5951

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

Documentation/git-checkout.adoc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,21 @@ Omitting _<branch>_ detaches `HEAD` at the tip of the current branch.
8282
`git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <pathspec>...`::
8383
`git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] --pathspec-from-file=<file> [--pathspec-file-nul]`::
8484
85-
Overwrite the contents of the files that match the pathspec.
86-
When the _<tree-ish>_ (most often a commit) is not given,
87-
overwrite working tree with the contents in the index.
88-
When the _<tree-ish>_ is given, overwrite both the index and
89-
the working tree with the contents at the _<tree-ish>_.
85+
Restore another version of the file(s) that match the pathspec.
9086
+
91-
The index may contain unmerged entries because of a previous failed merge.
92-
By default, if you try to check out such an entry from the index, the
93-
checkout operation will fail and nothing will be checked out.
94-
Using `-f` will ignore these unmerged entries. The contents from a
87+
If you specify a commit or tree to restore from (for example `git
88+
checkout main file.txt`), this will restore the version of the file(s)
89+
from that commit or tree. This overwrites the file in the working
90+
directory and stages the file's contents.
91+
+
92+
If you do not specify where to restore from (for example `git checkout
93+
file.txt`), this will replace the file(s) with the version from the index.
94+
If you check out a file with an unresolved merge
95+
conflict, the checkout operation will fail and no changes will be made.
96+
Using `-f` will ignore the merge conflict. The contents from a
9597
specific side of the merge can be checked out of the index by
9698
using `--ours` or `--theirs`. With `-m`, changes made to the working tree
9799
file can be discarded to re-create the original conflicted merge result.
98-
99100
`git checkout (-p|--patch) [<tree-ish>] [--] [<pathspec>...]`::
100101
This is similar to the previous mode, but lets you use the
101102
interactive interface to show the "diff" output and choose which

0 commit comments

Comments
 (0)