git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC/PATCH] Document "git-reset --merge"

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 4, 2008, 02:00 UTC
Message-ID
<7vprk87l8z.fsf_-_@gitster.siamese.dyndns.org>
In-Reply-To
<alpine.LFD.2.00.0812031634520.3256@nehalem.linux-foundation.org>

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>
---
 Documentation/git-reset.txt |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)
diff --git c/Documentation/git-reset.txt i/Documentation/git-reset.txt
index 52aab5e..c542b0c 100644
--- c/Documentation/git-reset.txt
+++ i/Documentation/git-reset.txt
@@ -8,7 +8,7 @@ git-reset - Reset current HEAD to the specified state
 SYNOPSIS
 --------
 [verse]
-'git reset' [--mixed | --soft | --hard] [-q] [<commit>]
+'git reset' [--mixed | --soft | --hard | --merge] [-q] [<commit>]
 'git reset' [-q] [<commit>] [--] <paths>...
 
 DESCRIPTION
@@ -45,6 +45,11 @@ OPTIONS
 	switched to. Any changes to tracked files in the working tree
 	since <commit> are lost.
 
+--merge::
+	Resets the index to match the tree recorded by the named commit,
+	and updates the files that are different between the named commit
+	and the current commit in the working tree.
+
 -q::
 	Be quiet, only report errors.
 
@@ -152,6 +157,28 @@ tip of the current branch in ORIG_HEAD, so resetting hard to it
 brings your index file and the working tree back to that state,
 and resets the tip of the branch to that commit.
 
+Undo a merge or pull inside a dirty work tree::
++
+------------
+$ git pull                         <1>
+Auto-merging nitfol
+Merge made by recursive.
+ nitfol                |   20 +++++----
+ ...
+$ git reset --merge ORIG_HEAD      <2>
+------------
++
+<1> Even if you may have local modifications in your
+working tree, you can safely say "git pull" when you know
+that the change in the other branch does not overlap with
+them.
+<2> After inspecting the result of the merge, you may find
+that the change in the other branch is unsatisfactory.  Running
+"git reset --hard ORIG_HEAD" will let you go back to where you
+were, but it will discard your local changes, which you do not
+want.  "git reset --merge" keeps your local changes.
+
+
 Interrupted workflow::
 +
 Suppose you are interrupted by an urgent fix request while you
Previous: Linus TorvaldsNext: Junio C Hamano
Message 7 of 8 in “Add 'sane' mode to 'git reset'”
  1. Linus TorvaldsDec 1, 2008
  2. Avery PennarunDec 1, 2008
  3. Jakub NarebskiDec 1, 2008
  4. Linus TorvaldsDec 1, 2008
  5. Junio C HamanoDec 3, 2008
  6. Linus TorvaldsDec 4, 2008
  7. Document "git-reset --merge"Junio C Hamano, Dec 4, 2008
  8. Junio C HamanoDec 4, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.