aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/git-checkout.adoc
diff options
context:
space:
mode:
authorJulia Evans <julia@jvns.ca>2025-09-10 19:14:28 +0000
committerJunio C Hamano <gitster@pobox.com>2025-09-10 14:32:05 -0700
commitbfe7b17c253eaeefc024ed7fef80787dd80d45fd (patch)
treeaaa9aa5bffc52964505ad6549a4b822a2c9fd126 /Documentation/git-checkout.adoc
parentdoc: git-checkout: deduplicate --detach explanation (diff)
downloadgit-bfe7b17c253eaeefc024ed7fef80787dd80d45fd.tar.gz
git-bfe7b17c253eaeefc024ed7fef80787dd80d45fd.zip
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. Restructuring so that `git checkout main file.txt` and `git checkout file.txt` are separate items will help us simplify the sentence structure a lot. 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 <julia@jvns.ca> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
-rw-r--r--Documentation/git-checkout.adoc23
1 files changed, 13 insertions, 10 deletions
diff --git a/Documentation/git-checkout.adoc b/Documentation/git-checkout.adoc
index 215fe40889..afc1880365 100644
--- a/Documentation/git-checkout.adoc
+++ b/Documentation/git-checkout.adoc
@@ -12,8 +12,8 @@ git checkout [-q] [-f] [-m] [<branch>]
git checkout [-q] [-f] [-m] --detach [<branch>]
git checkout [-q] [-f] [-m] [--detach] <commit>
git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new-branch>] [<start-point>]
-git checkout [-f] <tree-ish> [--] <pathspec>...
-git checkout [-f] <tree-ish> --pathspec-from-file=<file> [--pathspec-file-nul]
+git checkout <tree-ish> [--] <pathspec>...
+git checkout <tree-ish> --pathspec-from-file=<file> [--pathspec-file-nul]
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [--] <pathspec>...
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] --pathspec-from-file=<file> [--pathspec-file-nul]
git checkout (-p|--patch) [<tree-ish>] [--] [<pathspec>...]
@@ -72,14 +72,17 @@ uncommitted changes.
+
Omitting _<branch>_ detaches `HEAD` at the tip of the current branch.
-`git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <pathspec>...`::
-`git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] --pathspec-from-file=<file> [--pathspec-file-nul]`::
+`git checkout <tree-ish> [--] <pathspec>...`::
+`git checkout <tree-ish> --pathspec-from-file=<file> [--pathspec-file-nul]`::
- Overwrite the contents of the files that match the pathspec.
- When the _<tree-ish>_ (most often a commit) is not given,
- overwrite working tree with the contents in the index.
- When the _<tree-ish>_ is given, overwrite both the index and
- the working tree with the contents at the _<tree-ish>_.
+ Overwrite both the index and the working tree with the
+ contents at the _<tree-ish>_ for the files that match the pathspec.
+
+`git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [--] <pathspec>...`::
+`git checkout [-f|--ours|--theirs|-m|--conflict=<style>] --pathspec-from-file=<file> [--pathspec-file-nul]`::
+
+ Overwrite working tree with the contents in the index for the files
+ that match the pathspec.
+
The index may contain unmerged entries because of a previous failed merge.
By default, if you try to check out such an entry from the index, the
@@ -90,7 +93,7 @@ using `--ours` or `--theirs`. With `-m`, changes made to the working tree
file can be discarded to re-create the original conflicted merge result.
`git checkout (-p|--patch) [<tree-ish>] [--] [<pathspec>...]`::
- This is similar to the previous mode, but lets you use the
+ This is similar to the previous two modes, but lets you use the
interactive interface to show the "diff" output and choose which
hunks to use in the result. See below for the description of
`--patch` option.