-
Notifications
You must be signed in to change notification settings - Fork 157
doc: git-reset: clarify DESCRIPTION section #1991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,86 +3,65 @@ git-reset(1) | |
|
|
||
| NAME | ||
| ---- | ||
| git-reset - Reset current HEAD to the specified state | ||
| git-reset - Set HEAD to point at the specified commit | ||
|
|
||
| SYNOPSIS | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): "Julia Evans via GitGitGadget" <[email protected]> writes:
> diff --git a/Documentation/git-reset.adoc b/Documentation/git-reset.adoc
> index 3b9ba9aee9..9843682e81 100644
> --- a/Documentation/git-reset.adoc
> +++ b/Documentation/git-reset.adoc
> @@ -8,43 +8,17 @@ git-reset - Reset current HEAD to the specified state
> SYNOPSIS
> --------
> [synopsis]
> +git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>]
> git reset [-q] [<tree-ish>] [--] <pathspec>...
> git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>]
> git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>...]
> -git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>]
>
> DESCRIPTION
> -----------
> -In the first three forms, copy entries from _<tree-ish>_ to the index.
> -In the last form, set the current branch head (`HEAD`) to _<commit>_,
> +In the first form, set the current branch head (`HEAD`) to _<commit>_,
> optionally modifying index and working tree to match.
> The _<tree-ish>_/_<commit>_ defaults to `HEAD` in all forms.
In the original, the "defaults to HEAD in all forms" did make sense,
but as the new text does not mention there are three other forms
like the original did, that sentence was made harder to fathom.
I can accept that you do not want to get ahead of yourself to
explain "copy from <treeish>" before you are ready to talk more
about these other forms, but we'd at least need to acknowledge that
what we want to refer to when we say "all forms" here. Perhaps
Among the four forms, the first form sets the current branch
head to .... In all forms, the tree-ish/commit defaults to
HEAD.
is easier to read?
> +In the last three forms, copy entries from _<tree-ish>_ to the index.
Or "The other three forms copy entries ..."?
Other than that, looks good to me.There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, "Julia Evans" wrote (reply to this): On Fri, Oct 17, 2025, at 6:20 PM, Junio C Hamano wrote:
> "Julia Evans via GitGitGadget" <[email protected]> writes:
>
>> diff --git a/Documentation/git-reset.adoc b/Documentation/git-reset.adoc
>> index 3b9ba9aee9..9843682e81 100644
>> --- a/Documentation/git-reset.adoc
>> +++ b/Documentation/git-reset.adoc
>> @@ -8,43 +8,17 @@ git-reset - Reset current HEAD to the specified state
>> SYNOPSIS
>> --------
>> [synopsis]
>> +git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>]
>> git reset [-q] [<tree-ish>] [--] <pathspec>...
>> git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>]
>> git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>...]
>> -git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>]
>>
>> DESCRIPTION
>> -----------
>> -In the first three forms, copy entries from _<tree-ish>_ to the index.
>> -In the last form, set the current branch head (`HEAD`) to _<commit>_,
>> +In the first form, set the current branch head (`HEAD`) to _<commit>_,
>> optionally modifying index and working tree to match.
>> The _<tree-ish>_/_<commit>_ defaults to `HEAD` in all forms.
>
> In the original, the "defaults to HEAD in all forms" did make sense,
> but as the new text does not mention there are three other forms
> like the original did, that sentence was made harder to fathom.
That's true. I didn't pay very careful attention to the text here
because I completely rewrote it in a later patch anyway.
I'll make it say something that makes more sense.
> I can accept that you do not want to get ahead of yourself to
> explain "copy from <treeish>" before you are ready to talk more
> about these other forms, but we'd at least need to acknowledge that
> what we want to refer to when we say "all forms" here. Perhaps
>
> Among the four forms, the first form sets the current branch
> head to .... In all forms, the tree-ish/commit defaults to
> HEAD.
>
> is easier to read?
>
>> +In the last three forms, copy entries from _<tree-ish>_ to the index.
>
> Or "The other three forms copy entries ..."?
>
> Other than that, looks good to me. |
||
| -------- | ||
| [synopsis] | ||
| git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>] | ||
| git reset [-q] [<tree-ish>] [--] <pathspec>... | ||
| git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>] | ||
| git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>...] | ||
| git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [<commit>] | ||
|
|
||
| DESCRIPTION | ||
| ----------- | ||
| In the first three forms, copy entries from _<tree-ish>_ to the index. | ||
| In the last form, set the current branch head (`HEAD`) to _<commit>_, | ||
| optionally modifying index and working tree to match. | ||
| The _<tree-ish>_/_<commit>_ defaults to `HEAD` in all forms. | ||
|
|
||
| `git reset [-q] [<tree-ish>] [--] <pathspec>...`:: | ||
| `git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>]`:: | ||
| These forms reset the index entries for all paths that match the | ||
| _<pathspec>_ to their state at _<tree-ish>_. (It does not affect | ||
| the working tree or the current branch.) | ||
| + | ||
| This means that `git reset <pathspec>` is the opposite of `git add | ||
| <pathspec>`. This command is equivalent to | ||
| `git restore [--source=<tree-ish>] --staged <pathspec>...`. | ||
| + | ||
| After running `git reset <pathspec>` to update the index entry, you can | ||
| use linkgit:git-restore[1] to check the contents out of the index to | ||
| the working tree. Alternatively, using linkgit:git-restore[1] | ||
| and specifying a commit with `--source`, you | ||
| can copy the contents of a path out of a commit to the index and to the | ||
| working tree in one go. | ||
| `git reset [<mode>] <commit>` changes which commit HEAD points to. | ||
| This makes it possible to undo various Git operations, for example | ||
| commit, merge, rebase, and pull. | ||
|
|
||
| `git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>...]`:: | ||
| Interactively select hunks in the difference between the index | ||
| and _<tree-ish>_ (defaults to `HEAD`). The chosen hunks are applied | ||
| in reverse to the index. | ||
| + | ||
| This means that `git reset -p` is the opposite of `git add -p`, i.e. | ||
| you can use it to selectively reset hunks. See the "Interactive Mode" | ||
| section of linkgit:git-add[1] to learn how to operate the `--patch` mode. | ||
| However, when you specify files or directories or pass `--patch`, | ||
| `git reset` will instead update the staged version of the specified | ||
| files without updating HEAD. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): "Julia Evans via GitGitGadget" <[email protected]> writes:
> +`--soft`::
> + Leaves your working directory unchanged. The index is left unchanged,
Why not "leave your working tree files and the index unchanged"?
> + so everything in your current commit will be staged.
Hmph, if a reader still has the "stage the changes" mental model,
then this would be true only when you are resetting to HEAD~1 (this
is one of the reasons why I am hesitant to overuse the verb
"stage"). If you are going to HEAD~5, such a reader would say that
the changes made by the past 5 commits are staged, not just the
commit you are on before resetting.
> + For example, if you have no staged changes, you can use
> + `git reset --soft HEAD~5; git commit`
> + to combine the last 5 commits into 1 commit.
Another thing that may be worth mentioning is that you can do this
even with local changes in the working tree, because you do not give
"-a" to the final "git commit".
> `--hard`::
> - Resets the index and working tree. Any changes to tracked files in the
> - working tree since _<commit>_ are discarded. Any untracked files or
> - directories in the way of writing any tracked files are simply deleted.
> + Overwrites all files and directories with the version from _<commit>_,
> + and may overwrite untracked files.
> + Updates the index to match the new HEAD, so nothing will be staged.
One thing that may be worth saying is that the paths in the working
tree that are tracked in the index that are not in <commit> will
disappear.
> `--merge`::
> + Mainly exists for backwards compatibility: `git merge --abort` is the
> + usual way to abort a merge. See linkgit:git-merge[1] for the differences.
There are operations that are not "git merge" that can leave the
index in an unmerged state, and you do not want to use "git merge
--abort" to get out of such a state, I would imagine. So I have a
feeling that we are better off without these two lines.
> Resets the index and updates the files in the working tree that are
> different between _<commit>_ and `HEAD`, but keeps those which are
> different between the index and working tree (i.e. which have changes
> which have not been added).
> If a file that is different between _<commit>_ and the index has
> unstaged changes, reset is aborted.
> -+
> -In other words, `--merge` does something like a `git read-tree -u -m <commit>`,
> -but carries forward unmerged index entries.
I do not mind losing this. Unlike the time back when these two
lines were written, nobody knows (and more importantly, nobody has
to know) what "read-tree -u -m" does, these days.
> `--keep`::
> Resets index entries and updates files in the working tree that are
Thanks.There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, "Julia Evans" wrote (reply to this): On Sat, Oct 18, 2025, at 12:53 AM, Junio C Hamano wrote:
> "Julia Evans via GitGitGadget" <[email protected]> writes:
>
>> +`--soft`::
>> + Leaves your working directory unchanged. The index is left unchanged,
>
> Why not "leave your working tree files and the index unchanged"?
The reason I say "working directory" instead of "working tree" is that
I've seen a few comments from users saying that they don't know
what "working tree" means. I'm still not sure what the reason for
calling it a "working tree" is.
The reason for keeping them separate sentences is just for symmetry with
the other commands, and also because (like I mentioned in the commit
message) "leaving X and Y unchanged" makes it sound like leaving X and
Y unchanged is a "neutral operation", while actually leaving the index
unchanged while updating HEAD is actually a fairly weird thing to do.
>> + so everything in your current commit will be staged.
>
> Hmph, if a reader still has the "stage the changes" mental model,
> then this would be true only when you are resetting to HEAD~1 (this
> is one of the reasons why I am hesitant to overuse the verb
> "stage"). If you are going to HEAD~5, such a reader would say that
> the changes made by the past 5 commits are staged, not just the
> commit you are on before resetting.
That's fair. I'll try to think about whether there's a better way to say
this.
Previously it said "This leaves all your changed files
"Changes to be committed", as git status would put it.", which has the
same issue ("changed files" since when exactly?).
Maybe I can fix this by being more explicit about which changes
exactly will show up as "staged" in `git status`.
>> + For example, if you have no staged changes, you can use
>> + `git reset --soft HEAD~5; git commit`
>> + to combine the last 5 commits into 1 commit.
>
> Another thing that may be worth mentioning is that you can do this
> even with local changes in the working tree, because you do not give
> "-a" to the final "git commit".
Maybe! I'm not sure if we want to encourage doing complex Git operations
with unstaged changes though. I feel like it often leads to suffering
and I think people who want to do that can already infer that it's
possible.
>> `--hard`::
>> - Resets the index and working tree. Any changes to tracked files in the
>> - working tree since _<commit>_ are discarded. Any untracked files or
>> - directories in the way of writing any tracked files are simply deleted.
>> + Overwrites all files and directories with the version from _<commit>_,
>> + and may overwrite untracked files.
>> + Updates the index to match the new HEAD, so nothing will be staged.
>
> One thing that may be worth saying is that the paths in the working
> tree that are tracked in the index that are not in <commit> will
> disappear.
Interesting, I don't think I knew that. Would this be a more accurate
description of what `git reset --hard` does, conceptually?
I want to make sure I understand how it works.
1. List every file that's either in the target commit or in the index
2. For each file, make it match the target commit
(overwriting untracked files if necessary)
>> `--merge`::
>> + Mainly exists for backwards compatibility: `git merge --abort` is the
>> + usual way to abort a merge. See linkgit:git-merge[1] for the differences.
>
> There are operations that are not "git merge" that can leave the
> index in an unmerged state, and you do not want to use "git merge
> --abort" to get out of such a state, I would imagine. So I have a
> feeling that we are better off without these two lines.
Do you mean `git reset` and `git cherry-pick`, or are there other operations
that can leave the operation in an unmerged state?
My mental model is that if there's a merge conflict, the best way to deal with it
is to use the appropriate `--abort` command (depending on how you got there),
because the command-specific `--abort` will know how to do things like
restore autostashed changes. But I agree that just saying "use `git merge --abort`
is not a complete description.
>> Resets the index and updates the files in the working tree that are
>> different between _<commit>_ and `HEAD`, but keeps those which are
>> different between the index and working tree (i.e. which have changes
>> which have not been added).
>> If a file that is different between _<commit>_ and the index has
>> unstaged changes, reset is aborted.
>> -+
>> -In other words, `--merge` does something like a `git read-tree -u -m <commit>`,
>> -but carries forward unmerged index entries.
>
> I do not mind losing this. Unlike the time back when these two
> lines were written, nobody knows (and more importantly, nobody has
> to know) what "read-tree -u -m" does, these days.
Thanks, it's useful for me to know more about the context at the time
this was written.There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, "D. Ben Knoble" wrote (reply to this): On Mon, Oct 20, 2025 at 4:28 PM Julia Evans <[email protected]> wrote:
>
> On Sat, Oct 18, 2025, at 12:53 AM, Junio C Hamano wrote:
> > "Julia Evans via GitGitGadget" <[email protected]> writes:
> >
> >> +`--soft`::
> >> + Leaves your working directory unchanged. The index is left unchanged,
> >
> > Why not "leave your working tree files and the index unchanged"?
>
> The reason I say "working directory" instead of "working tree" is that
> I've seen a few comments from users saying that they don't know
> what "working tree" means. I'm still not sure what the reason for
> calling it a "working tree" is.
At a guess: suppose I have a non-bare repository ~/code/git with
corresponding ~/code/git/.git directory, but PWD=~/code/git/t. Then my
working directory is "…/t" but my working tree includes all the stuff
Git is tracking above me, too! (It also helps draw parallelism with
git-worktree, but that's a bit circular.)There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): "Julia Evans" <[email protected]> writes:
> On Sat, Oct 18, 2025, at 12:53 AM, Junio C Hamano wrote:
>> "Julia Evans via GitGitGadget" <[email protected]> writes:
>>
>>> +`--soft`::
>>> + Leaves your working directory unchanged. The index is left unchanged,
>>
>> Why not "leave your working tree files and the index unchanged"?
>
> The reason I say "working directory" instead of "working tree" is that
> I've seen a few comments from users saying that they don't know
> what "working tree" means. I'm still not sure what the reason for
> calling it a "working tree" is.
"working tree" refers to the directory that is the top level of a
checkout; I'd view (current) "working directory" can be anything
$(pwd), that may be outside control of any git repository, and that
is why I tend to avoid the latter when I want to be more precise
(and "worktree" is another thing---used to refer to one particular
"working tree" among other working trees attached to the same
repository).
But that distinction was not the part I wanted to comment on. The
question was about two sentences talking about two things
separately. IOW
Leave your working directory and the index unchanged.
is what I would have expected, and I was wondering why they are
treated separately. After all, the index is part of your working
tree state.
> The reason for keeping them separate sentences is just for symmetry with
> the other commands, and also because (like I mentioned in the commit
> message) "leaving X and Y unchanged" makes it sound like leaving X and
> Y unchanged is a "neutral operation", while actually leaving the index
> unchanged while updating HEAD is actually a fairly weird thing to do.
Sorry, but I do not understand this comment.
The index and the HEAD are two different things, and it is natural
that they can move independently. After all we update the former
without updating the latter all the time (it is called "git add").
Besides, the two things the --soft does not touch are the files in
the working tree and the index. The index has what you want to make
the next commit out of, and the working tree has the state that may
come after that state in the index. Keeping both of them intact
when moving HEAD around is one natural thing to do when you want to
squash the previous N commits after "git add <paths>" by doing "git
reset --soft HEAD~N && git commit". Contrasting to that, "--mixed"
would leave the files in the working tree intact, while matching the
index to the HEAD you are moving to, essentially undoing your "git
add"s before you decided to reset. That's another natural thing to
do when you decide to keep the clean slate and rebuild your index from
scratch to prepare for a commit that comes on top of the commit you
are moving to.
So, no, I do not understand the above comment.
> Do you mean `git reset` and `git cherry-pick`, or are there other operations
> that can leave the operation in an unmerged state?
There are many commands that leaves the index unmerged, like "am
-3", "rebase", "switch -m", "stash pop", etc.
|
||
|
|
||
| `git reset [<mode>] [<commit>]`:: | ||
| This form resets the current branch head to _<commit>_ and | ||
| possibly updates the index (resetting it to the tree of _<commit>_) and | ||
| the working tree depending on _<mode>_. Before the operation, `ORIG_HEAD` | ||
| is set to the tip of the current branch. If _<mode>_ is omitted, | ||
| defaults to `--mixed`. The _<mode>_ must be one of the following: | ||
| Set the current branch head (`HEAD`) to point at _<commit>_. | ||
| Depending on _<mode>_, also update the working directory and/or index | ||
| to match the contents of _<commit>_. | ||
| _<commit>_ defaults to `HEAD`. | ||
| Before the operation, `ORIG_HEAD` is set to the tip of the current branch. | ||
| + | ||
| The _<mode>_ must be one of the following (default `--mixed`): | ||
| + | ||
| -- | ||
| `--soft`:: | ||
| Does not touch the index file or the working tree at all (but | ||
| resets the head to _<commit>_, just like all modes do). This leaves | ||
| all your changed files "Changes to be committed", as `git status` | ||
| would put it. | ||
|
|
||
| -- | ||
| `--mixed`:: | ||
| Resets the index but not the working tree (i.e., the changed files | ||
| are preserved but not marked for commit) and reports what has not | ||
| been updated. This is the default action. | ||
| Leaves your working directory unchanged. | ||
| Updates the index to match the new HEAD, so nothing will be staged. | ||
| + | ||
| If `-N` is specified, removed paths are marked as intent-to-add (see | ||
| linkgit:git-add[1]). | ||
|
|
||
| `--soft`:: | ||
| Leaves your working directory unchanged. The index is left unchanged, | ||
| so everything in your current commit will be staged. | ||
| For example, if you have no staged changes, you can use | ||
| `git reset --soft HEAD~5; git commit` | ||
| to combine the last 5 commits into 1 commit. | ||
|
|
||
| `--hard`:: | ||
| Resets the index and working tree. Any changes to tracked files in the | ||
| working tree since _<commit>_ are discarded. Any untracked files or | ||
| directories in the way of writing any tracked files are simply deleted. | ||
| Overwrites all files and directories with the version from _<commit>_, | ||
| and may overwrite untracked files. | ||
| Updates the index to match the new HEAD, so nothing will be staged. | ||
|
|
||
| `--merge`:: | ||
| Mainly exists for backwards compatibility: `git merge --abort` is the | ||
| usual way to abort a merge. See linkgit:git-merge[1] for the differences. | ||
| Resets the index and updates the files in the working tree that are | ||
| different between _<commit>_ and `HEAD`, but keeps those which are | ||
| different between the index and working tree (i.e. which have changes | ||
| which have not been added). | ||
| If a file that is different between _<commit>_ and the index has | ||
| unstaged changes, reset is aborted. | ||
| + | ||
| In other words, `--merge` does something like a `git read-tree -u -m <commit>`, | ||
| but carries forward unmerged index entries. | ||
|
|
||
| `--keep`:: | ||
| Resets index entries and updates files in the working tree that are | ||
|
|
@@ -98,6 +77,27 @@ but carries forward unmerged index entries. | |
| the submodules' `HEAD` to be detached at that commit. | ||
| -- | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): "Julia Evans via GitGitGadget" <[email protected]> writes:
> +`git reset` only modifies the index: use linkgit:git-restore[1] instead
> +if you'd like to also update the file in your working directory.
I cannot judge if it is clear enough with the above sentence that we
are only talking about "the other forms", but if that is the case
and it is clear we are not talking about the mode where the command
repoints HEAD to another commit, the above is a good piece of advice.
If not, perhaps
When specified what paths to modify, `git reset` updates only
the index (without updating the HEAD or working tree files). If
you want to update the files as well as the index entries, use
git-restore.
may be a way to clarify the distinction between two modes.
> `git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>...]`::
> - Interactively select hunks in the difference between the index
> - and _<tree-ish>_ (defaults to `HEAD`). The chosen hunks are applied
> - in reverse to the index.
> + Interactively select changes from the difference between the index
> + and the specified commit or tree (which defaults to `HEAD`).
> + The chosen changes are unstaged.
> +
> This means that `git reset -p` is the opposite of `git add -p`, i.e.
> -you can use it to selectively reset hunks. See the "Interactive Mode"
> -section of linkgit:git-add[1] to learn how to operate the `--patch` mode.
> +you can use it to selectively unstage changes. See the "Interactive Mode"
> +section of linkgit:git-add[1] to learn how to use the `--patch` option.
I do not see a good reason why we avoid saying the noun "patch",
especially when we see it in the option. If we were allowed to say
"patch" here, "changes from the difference between ..." can be
rephrased to "parts of the patch that makes the index match the
specified commit", which may be simpler.
Also "unstaged" is only true when <tree-ish> is "HEAD". If you are
grabbing the contents recorded in a different commit and shoving
them into the index, that is not "unstaging" at all. Rather, if you
are planning to make a commit out of the index after doing so, that
is rather "staging" a change! While the verb "to (un)stage" may
have been a useful tool to explain the act of updating index entries
to describe its effect relative to what is in HEAD, in this
particular case, it is probably more confusing than illuninating to
use it.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Ben Knoble wrote (reply to this): > Le 17 oct. 2025 à 19:25, Junio C Hamano <[email protected]> a écrit :
>
> "Julia Evans via GitGitGadget" <[email protected]> writes:
>
>> `git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>...]`::
>> - Interactively select hunks in the difference between the index
>> - and _<tree-ish>_ (defaults to `HEAD`). The chosen hunks are applied
>> - in reverse to the index.
>> + Interactively select changes from the difference between the index
>> + and the specified commit or tree (which defaults to `HEAD`).
>> + The chosen changes are unstaged.
>> +
>> This means that `git reset -p` is the opposite of `git add -p`, i.e.
>> -you can use it to selectively reset hunks. See the "Interactive Mode"
>> -section of linkgit:git-add[1] to learn how to operate the `--patch` mode.
>> +you can use it to selectively unstage changes. See the "Interactive Mode"
>> +section of linkgit:git-add[1] to learn how to use the `--patch` option.
>
> I do not see a good reason why we avoid saying the noun "patch",
> especially when we see it in the option. If we were allowed to say
> "patch" here, "changes from the difference between ..." can be
> rephrased to "parts of the patch that makes the index match the
> specified commit", which may be simpler.
I think the issue was the word « hunk », not « patch ».There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): Ben Knoble <[email protected]> writes:
>> Le 17 oct. 2025 à 19:25, Junio C Hamano <[email protected]> a écrit :
>>
>> "Julia Evans via GitGitGadget" <[email protected]> writes:
>>
>>> `git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>...]`::
>>> - Interactively select hunks in the difference between the index
>>> - and _<tree-ish>_ (defaults to `HEAD`). The chosen hunks are applied
>>> - in reverse to the index.
>>> + Interactively select changes from the difference between the index
>>> + and the specified commit or tree (which defaults to `HEAD`).
>>> + The chosen changes are unstaged.
>>> +
>>> This means that `git reset -p` is the opposite of `git add -p`, i.e.
>>> -you can use it to selectively reset hunks. See the "Interactive Mode"
>>> -section of linkgit:git-add[1] to learn how to operate the `--patch` mode.
>>> +you can use it to selectively unstage changes. See the "Interactive Mode"
>>> +section of linkgit:git-add[1] to learn how to use the `--patch` option.
>>
>> I do not see a good reason why we avoid saying the noun "patch",
>> especially when we see it in the option. If we were allowed to say
>> "patch" here, "changes from the difference between ..." can be
>> rephrased to "parts of the patch that makes the index match the
>> specified commit", which may be simpler.
>
> I think the issue was the word « hunk », not « patch ».
I know. That is exactly where my question comes from. |
||
| `git reset [-q] [<tree-ish>] [--] <pathspec>...`:: | ||
| `git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>]`:: | ||
| For all specified files or directories, set the staged version to | ||
| the version from the given commit or tree (which defaults to `HEAD`). | ||
| + | ||
| This means that `git reset <pathspec>` is the opposite of `git add | ||
| <pathspec>`: it unstages all changes to the specified file(s) or | ||
| directories. This is equivalent to `git restore --staged <pathspec>...`. | ||
| + | ||
| `git reset` only modifies the index: use linkgit:git-restore[1] instead | ||
| if you'd like to also update the file in your working directory. | ||
|
|
||
| `git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>...]`:: | ||
| Interactively select changes from the difference between the index | ||
| and the specified commit or tree (which defaults to `HEAD`). | ||
| The chosen changes are unstaged. | ||
| + | ||
| This means that `git reset -p` is the opposite of `git add -p`, i.e. | ||
| you can use it to selectively unstage changes. See the "Interactive Mode" | ||
| section of linkgit:git-add[1] to learn how to use the `--patch` option. | ||
|
|
||
| See "Reset, restore and revert" in linkgit:git[1] for the differences | ||
| between the three commands. | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, "Julia Evans" wrote (reply to this):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, "D. Ben Knoble" wrote (reply to this):