@@ -74,23 +74,27 @@ Omitting _<branch>_ detaches `HEAD` at the tip of the current branch.
7474`git checkout <tree-ish > [-- ] <pathspec> ...` ::
7575`git checkout <tree-ish > --pathspec-from-file=<file> [--pathspec-file-nul ]`::
7676
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`.
7982
8083`git checkout [-f |--ours |--theirs |-m |--conflict = <style> ] [-- ] <pathspec> ...` ::
8184`git checkout [-f |--ours |--theirs |-m |--conflict = <style> ] --pathspec-from-file=<file> [--pathspec-file-nul ]`::
8285
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.
8591+
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.
9498`git checkout (-p |--patch) [<tree-ish>] [-- ] [<pathspec>...]`::
9599 This is similar to the previous two modes, but lets you use the
96100 interactive interface to show the "diff" output and choose which
0 commit comments