@@ -3,86 +3,65 @@ git-reset(1)
33
44NAME
55---- 
6- git-reset - Reset current  HEAD to the specified state 
6+ git-reset - Set  HEAD to point at  the specified commit 
77
88SYNOPSIS
99-------- 
1010[synopsis] 
11+ git reset [-- soft | -- mixed [-N] | -- hard | -- merge | -- keep] [-q] [<commit >]
1112git reset [-q] [<tree-ish >] [-- ] <pathspec >... 
1213git reset [-q] [-- pathspec-from-file=<file > [-- pathspec-file-nul]] [<tree-ish >]
1314git reset (-- patch | -p) [<tree-ish >] [-- ] [<pathspec >... ]
14- git reset [-- soft | -- mixed [-N] | -- hard | -- merge | -- keep] [-q] [<commit >]
1515
1616DESCRIPTION
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>_ ,
20- optionally modifying index and working tree to match.
21- 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.
18+ `git reset [<mode>] <commit>`  changes which commit HEAD points to.
19+ This makes it possible to undo various Git operations, for example
20+ commit, merge, rebase, and pull.
3921
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.
22+ However, when you specify files or directories or pass `--patch` ,
23+ `git reset`  will instead update the staged version of the specified
24+ files without updating HEAD.
4825
4926`git reset [<mode>] [<commit>]` ::
50- 	This form resets the current branch head to _<commit>_  and
51- 	possibly updates the index (resetting it to the tree of _<commit>_ ) and
52- 	the working tree depending on _<mode>_ . Before the operation, `ORIG_HEAD` 
53- 	is set to the tip of the current branch. If _<mode>_  is omitted,
54- 	defaults to `--mixed` . The _<mode>_  must be one of the following:
27+ 	Set the current branch head (`HEAD` ) to point at _<commit>_ .
28+ 	Depending on _<mode>_ , also update the working directory and/or index
29+ 	to match the contents of _<commit>_ .
30+ 	_<commit>_  defaults to `HEAD` .
31+ 	Before the operation, `ORIG_HEAD`  is set to the tip of the current branch.
32+ +
33+ The _<mode>_  must be one of the following (default `--mixed` ):
5534+
56- -- 
57- `--soft` ::
58- 	Does not touch the index file or the working tree at all (but
59- 	resets the head to _<commit>_ , just like all modes do). This leaves
60- 	all your changed files "Changes to be committed", as `git status` 
61- 	would put it.
6235
36+ -- 
6337`--mixed` ::
64- 	Resets the index but not the working tree (i.e., the changed files
65- 	are preserved but not marked for commit) and reports what has not
66- 	been updated. This is the default action.
38+ 	Leaves your working directory unchanged.
39+ 	Updates the index to match the new HEAD, so nothing will be staged.
6740+
6841If `-N`  is specified, removed paths are marked as intent-to-add (see
6942linkgit:git-add[1]).
7043
44+ `--soft` ::
45+ 	Leaves your working directory unchanged. The index is left unchanged,
46+ 	so everything in your current commit will be staged.
47+ 	For example, if you have no staged changes, you can use
48+ 	`git reset --soft HEAD~5; git commit` 
49+ 	to combine the last 5 commits into 1 commit.
50+ 
7151`--hard` ::
72- 	Resets the index  and working tree. Any changes to tracked files in the 
73- 	working tree since  _<commit>_  are discarded.  Any  untracked files or 
74- 	directories in  the way of writing any tracked files are simply deleted .
52+ 	Overwrites all files  and directories with the version from  _<commit>_ , 
53+ 	and may overwrite  untracked files. 
54+ 	Updates  the index to match the new HEAD, so nothing will be staged .
7555
7656`--merge` ::
57+ 	Mainly exists for backwards compatibility: `git merge --abort`  is the
58+ 	usual way to abort a merge. See linkgit:git-merge[1] for the differences.
7759	Resets the index and updates the files in the working tree that are
7860	different between _<commit>_  and `HEAD` , but keeps those which are
7961	different between the index and working tree (i.e. which have changes
8062	which have not been added).
8163	If a file that is different between _<commit>_  and the index has
8264	unstaged changes, reset is aborted.
83- +
84- In other words, `--merge`  does something like a `git read-tree -u -m <commit>` ,
85- but carries forward unmerged index entries.
8665
8766`--keep` ::
8867	Resets index entries and updates files in the working tree that are
@@ -98,6 +77,27 @@ but carries forward unmerged index entries.
9877	the submodules' `HEAD`  to be detached at that commit.
9978-- 
10079
80+ `git reset [-q] [<tree-ish>] [--] <pathspec>...` ::
81+ `git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>]` ::
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` ).
84+ +
85+ This means that `git reset <pathspec>`  is the opposite of `git add
86+ <pathspec >`: it unstages all changes to the specified file(s) or
87+ directories. This is equivalent to `git restore --staged <pathspec>...` .
88+ +
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.
91+ 
92+ `git reset (--patch | -p) [<tree-ish>] [--] [<pathspec>...]` ::
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.
96+ +
97+ This means that `git reset -p`  is the opposite of `git add -p` , i.e.
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.
100+ 
101101See "Reset, restore and revert" in linkgit:git[1] for the differences
102102between the three commands.
103103
0 commit comments