Skip to content

Commit 0b9583f

Browse files
jvnsgitster
authored andcommitted
doc: git-reset: clarify git reset <pathspec>
>From user feedback: - Continued confusion about the terms "tree-ish" and "pathspec" - The word "hunks" is confusing folks, use "changes" instead. - On the part about `git restore`, there were a few comments to the effect of "wait, this doesn't actually update any files? What? Why?" Be more direct that `git reset` does not update files: there's no obvious reason to suggest that folks use `git reset` followed by `git restore`, instead suggest just using `git restore`. Continue avoiding the use of the word "reset" to describe what "git reset" does. Signed-off-by: Julia Evans <julia@jvns.ca> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 84aed17 commit 0b9583f

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

Documentation/git-reset.adoc

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,29 +79,24 @@ linkgit:git-add[1]).
7979

8080
`git reset [-q] [<tree-ish>] [--] <pathspec>...`::
8181
`git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>]`::
82-
These forms reset the index entries for all paths that match the
83-
_<pathspec>_ to their state at _<tree-ish>_. (It does not affect
84-
the working tree or the current branch.)
82+
For all specified files or directories, set the staged version to
83+
the version from the given commit or tree (which defaults to `HEAD`).
8584
+
8685
This means that `git reset <pathspec>` is the opposite of `git add
87-
<pathspec>`. This command is equivalent to
88-
`git restore [--source=<tree-ish>] --staged <pathspec>...`.
86+
<pathspec>`: it unstages all changes to the specified file(s) or
87+
directories. This is equivalent to `git restore --staged <pathspec>...`.
8988
+
90-
After running `git reset <pathspec>` to update the index entry, you can
91-
use linkgit:git-restore[1] to check the contents out of the index to
92-
the working tree. Alternatively, using linkgit:git-restore[1]
93-
and specifying a commit with `--source`, you
94-
can copy the contents of a path out of a commit to the index and to the
95-
working tree in one go.
89+
`git reset` only modifies the index: use linkgit:git-restore[1] instead
90+
if you'd like to also update the file in your working directory.
9691

9792
`git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>...]`::
98-
Interactively select hunks in the difference between the index
99-
and _<tree-ish>_ (defaults to `HEAD`). The chosen hunks are applied
100-
in reverse to the index.
93+
Interactively select changes from the difference between the index
94+
and the specified commit or tree (which defaults to `HEAD`).
95+
The chosen changes are unstaged.
10196
+
10297
This means that `git reset -p` is the opposite of `git add -p`, i.e.
103-
you can use it to selectively reset hunks. See the "Interactive Mode"
104-
section of linkgit:git-add[1] to learn how to operate the `--patch` mode.
98+
you can use it to selectively unstage changes. See the "Interactive Mode"
99+
section of linkgit:git-add[1] to learn how to use the `--patch` option.
105100

106101
See "Reset, restore and revert" in linkgit:git[1] for the differences
107102
between the three commands.

0 commit comments

Comments
 (0)