Document "git-reset --merge"
The commit log message for the feature made it sound as if this is a saner version of --mixed, but the use case presented makes it clear that it is a better variant of --hard when your changes and somebody else's changes are mixed together. Perhaps we would want to rewrite the example that shows the use of --hard not to talk about recovering from a failed merge? Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Dec 3, 2008 at 18:00 UTC
1b5b465fbde9515e04bd1e8524a208c92af3555e
1 file changed
+28
-1
Documentation/git-reset.txt
+28
-1
@@ -8,7 +8,7 @@ git-reset - Reset current HEAD to the specified state
8
SYNOPSIS
9
--------
10
[verse]
11
-'git reset' [--mixed | --soft | --hard] [-q] [<commit>]
11
+'git reset' [--mixed | --soft | --hard | --merge] [-q] [<commit>]
12
'git reset' [-q] [<commit>] [--] <paths>...
13
14
DESCRIPTION
@@ -45,6 +45,11 @@ OPTIONS
45
switched to. Any changes to tracked files in the working tree
46
since <commit> are lost.
47
48
+--merge::
49
+ Resets the index to match the tree recorded by the named commit,
50
+ and updates the files that are different between the named commit
51
+ and the current commit in the working tree.
52
+
53
-q::
54
Be quiet, only report errors.
55
@@ -152,6 +157,28 @@ tip of the current branch in ORIG_HEAD, so resetting hard to it
157
brings your index file and the working tree back to that state,
158
and resets the tip of the branch to that commit.
159
160
+Undo a merge or pull inside a dirty work tree::
161
++
162
+------------
163
+$ git pull <1>
164
+Auto-merging nitfol
165
+Merge made by recursive.
166
+ nitfol | 20 +++++----
167
+ ...
168
+$ git reset --merge ORIG_HEAD <2>
169
+------------
170
++
171
+<1> Even if you may have local modifications in your
172
+working tree, you can safely say "git pull" when you know
173
+that the change in the other branch does not overlap with
174
+them.
175
+<2> After inspecting the result of the merge, you may find
176
+that the change in the other branch is unsatisfactory. Running
177
+"git reset --hard ORIG_HEAD" will let you go back to where you
178
+were, but it will discard your local changes, which you do not
179
+want. "git reset --merge" keeps your local changes.
180
+
181
+
182
Interrupted workflow::
183
+
184
Suppose you are interrupted by an urgent fix request while you