Skip to content

Commit c7e1c09

Browse files
committed
doc: git-reset: reorder the forms
From user feedback: three users commented that the `git reset [mode]` form is the one that they primarily use, and that they were suprised to see it listed last. ("I've never used git reset in any mode other than --hard"). Move it to be first, since the `git reset [mode]` form is what "Reset current HEAD to the specified state" at the beginning refers to, and because the `git reset [mode]` form is the only thing that `git reset` uniquely does, the others could also be done with `git restore`. Signed-off-by: Julia Evans <julia@jvns.ca>
1 parent a483264 commit c7e1c09

1 file changed

Lines changed: 29 additions & 29 deletions

File tree

Documentation/git-reset.adoc

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,17 @@ git-reset - Reset current HEAD to the specified state
88
SYNOPSIS
99
--------
1010
[synopsis]
11+
git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>]
1112
git reset [-q] [<tree-ish>] [--] <pathspec>...
1213
git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>]
1314
git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>...]
14-
git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>]
1515

1616
DESCRIPTION
1717
-----------
18-
In the first three forms, copy entries from _<tree-ish>_ to the index.
19-
In the last form, set the current branch head (`HEAD`) to _<commit>_,
18+
In the first form, set the current branch head (`HEAD`) to _<commit>_,
2019
optionally modifying index and working tree to match.
2120
The _<tree-ish>_/_<commit>_ defaults to `HEAD` in all forms.
22-
23-
`git reset [-q] [<tree-ish>] [--] <pathspec>...`::
24-
`git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>]`::
25-
These forms reset the index entries for all paths that match the
26-
_<pathspec>_ to their state at _<tree-ish>_. (It does not affect
27-
the working tree or the current branch.)
28-
+
29-
This means that `git reset <pathspec>` is the opposite of `git add
30-
<pathspec>`. This command is equivalent to
31-
`git restore [--source=<tree-ish>] --staged <pathspec>...`.
32-
+
33-
After running `git reset <pathspec>` to update the index entry, you can
34-
use linkgit:git-restore[1] to check the contents out of the index to
35-
the working tree. Alternatively, using linkgit:git-restore[1]
36-
and specifying a commit with `--source`, you
37-
can copy the contents of a path out of a commit to the index and to the
38-
working tree in one go.
39-
40-
`git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>...]`::
41-
Interactively select hunks in the difference between the index
42-
and _<tree-ish>_ (defaults to `HEAD`). The chosen hunks are applied
43-
in reverse to the index.
44-
+
45-
This means that `git reset -p` is the opposite of `git add -p`, i.e.
46-
you can use it to selectively reset hunks. See the "Interactive Mode"
47-
section of linkgit:git-add[1] to learn how to operate the `--patch` mode.
21+
In the last three forms, copy entries from _<tree-ish>_ to the index.
4822

4923
`git reset [<mode>] [<commit>]`::
5024
This form resets the current branch head to _<commit>_ and
@@ -98,6 +72,32 @@ but carries forward unmerged index entries.
9872
the submodules' `HEAD` to be detached at that commit.
9973
--
10074

75+
`git reset [-q] [<tree-ish>] [--] <pathspec>...`::
76+
`git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>]`::
77+
These forms reset the index entries for all paths that match the
78+
_<pathspec>_ to their state at _<tree-ish>_. (It does not affect
79+
the working tree or the current branch.)
80+
+
81+
This means that `git reset <pathspec>` is the opposite of `git add
82+
<pathspec>`. This command is equivalent to
83+
`git restore [--source=<tree-ish>] --staged <pathspec>...`.
84+
+
85+
After running `git reset <pathspec>` to update the index entry, you can
86+
use linkgit:git-restore[1] to check the contents out of the index to
87+
the working tree. Alternatively, using linkgit:git-restore[1]
88+
and specifying a commit with `--source`, you
89+
can copy the contents of a path out of a commit to the index and to the
90+
working tree in one go.
91+
92+
`git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>...]`::
93+
Interactively select hunks in the difference between the index
94+
and _<tree-ish>_ (defaults to `HEAD`). The chosen hunks are applied
95+
in reverse to the index.
96+
+
97+
This means that `git reset -p` is the opposite of `git add -p`, i.e.
98+
you can use it to selectively reset hunks. See the "Interactive Mode"
99+
section of linkgit:git-add[1] to learn how to operate the `--patch` mode.
100+
101101
See "Reset, restore and revert" in linkgit:git[1] for the differences
102102
between the three commands.
103103

0 commit comments

Comments
 (0)