@@ -74,23 +74,27 @@ Omitting _<branch>_ detaches `HEAD` at the tip of the current branch.
74
74
`git checkout <tree-ish > [-- ] <pathspec> ...` ::
75
75
`git checkout <tree-ish > --pathspec-from-file=<file> [--pathspec-file-nul ]`::
76
76
77
- Overwrite both the index and the working tree with the
78
- contents at the _<tree-ish > _ for the files that match the pathspec.
77
+ Replace the specified files and/or directories with the version from
78
+ the given commit or tree and stage the files' contents.
79
+ +
80
+ For example, `git checkout main file.txt` will replace `file.txt`
81
+ with the version from `main`.
79
82
80
83
`git checkout [-f |--ours |--theirs |-m |--conflict = <style> ] [-- ] <pathspec> ...` ::
81
84
`git checkout [-f |--ours |--theirs |-m |--conflict = <style> ] --pathspec-from-file=<file> [--pathspec-file-nul ]`::
82
85
83
- Overwrite working tree with the contents in the index for the files
84
- that match the pathspec.
86
+ Discard any unstaged changes to the specified files and/or directories.
87
+ This works by copying the file from the index to your working directory.
88
+ For example, `git checkout file.txt` will replace `file.txt` with either
89
+ the staged version of `file.txt` (if there is one) or the version from the
90
+ current commit.
85
91
+
86
- The index may contain unmerged entries because of a previous failed merge.
87
- By default, if you try to check out such an entry from the index, the
88
- checkout operation will fail and nothing will be checked out.
89
- Using `-f` will ignore these unmerged entries. The contents from a
90
- specific side of the merge can be checked out of the index by
91
- using `--ours` or `--theirs`. With `-m`, changes made to the working tree
92
- file can be discarded to re-create the original conflicted merge result.
93
-
92
+ This will fail if the file has a merge conflict and you haven't yet run
93
+ `git add file.txt` (or something equivalent) to mark it as resolved.
94
+ You can use `-f` to ignore the unmerged files instead of failing, use
95
+ `--ours` or `--theirs` to replace them with the version from a specific
96
+ side of the merge, or use `-m` to replace them with the original
97
+ conflicted merge result.
94
98
`git checkout (-p |--patch) [<tree-ish>] [-- ] [<pathspec>...]`::
95
99
This is similar to the previous two modes, but lets you use the
96
100
interactive interface to show the "diff" output and choose which
0 commit comments