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> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Julia Evans committed
Jan 5, 2026 at 16:48 UTC
b767867fae892f15cdfd1466983fe4be46014a36
1 file changed
+29
-29
Documentation/git-reset.adoc
+29
-29
@@ -8,43 +8,17 @@ git-reset - Reset current HEAD to the specified state
8
SYNOPSIS
9
--------
10
[synopsis]
11
+git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>]
12
git reset [-q] [<tree-ish>] [--] <pathspec>...
13
git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>]
14
git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>...]
14
-git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>]
15
16
DESCRIPTION
17
-----------
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>_,
19
optionally modifying index and working tree to match.
20
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.
22
23
`git reset [<mode>] [<commit>]`::
24
This form resets the current branch head to _<commit>_ and
@@ -98,6 +72,32 @@ but carries forward unmerged index entries.
72
the submodules' `HEAD` to be detached at that commit.
73
--
74
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
+
101
See "Reset, restore and revert" in linkgit:git[1] for the differences
102
between the three commands.
103