From: Jonathan Nieder <jrnieder@gmail.com>
To: git@vger.kernel.org
Cc: bebarino@gmail.com, srabbelier@gmail.com,
Thomas Rast <trast@student.ethz.ch>,
Jakub Narebski <jnareb@gmail.com>,
Christian Couder <chriscool@tuxfamily.org>,
Johan Herland <johan@herland.net>
Subject: [RFC/PATCH 1/2] Documentation: suggest "reset --merge" more often
Date: Fri, 29 Oct 2010 03:38:36 -0500 [thread overview]
Message-ID: <20101029083836.GB26290@burratino> (raw)
In-Reply-To: <20101029083516.GA26290@burratino>
With its new semantics, "git reset --merge" is more suitable for
undoing a failed merge than "git reset --hard" is. It is especially
nice if you forget that you are in a merge and make a change or two:
git merge something-complicated
... notice conflicts, walk away ...
vi foo.c
git commit; # fails because the index has unmerged entries
git reset --merge
The modern (post-1.7.0) semantics of git reset --merge ensure that
the changes to foo.c will be preserved by this sequence of commands,
unless foo.c was one of the files with conflicts.
So in the spirit of ed4a6baa (Documentation: suggest `reset --merge`
in How Merge Works section, 2010-01-23), recommend it in place of
"reset --hard".
One caveat: for habitual adders-to-index, "git reset --merge" is
no better than "git reset --hard" (though still no worse).
vi foo.c
git add -u
git diff --cached --check; # fails because conflict markers are present
git reset --merge; # equivalent to git reset --hard
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Documentation/git-merge.txt | 2 +-
Documentation/git-reset.txt | 9 +++++----
Documentation/user-manual.txt | 9 ++++++++-
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index 84043cc..498931b 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -213,7 +213,7 @@ After seeing a conflict, you can do two things:
* Decide not to merge. The only clean-ups you need are to reset
the index file to the `HEAD` commit to reverse 2. and to clean
- up working tree changes made by 2. and 3.; `git-reset --hard` can
+ up working tree changes made by 2. and 3.; `git reset --merge` can
be used for this.
* Resolve the conflicts. Git will mark the conflicts in
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index fd72976..1d0d9e6 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -179,7 +179,7 @@ $ git pull <1>
Auto-merging nitfol
CONFLICT (content): Merge conflict in nitfol
Automatic merge failed; fix conflicts and then commit the result.
-$ git reset --hard <2>
+$ git reset --merge <2>
$ git pull . topic/branch <3>
Updating from 41223... to 13134...
Fast-forward
@@ -189,9 +189,10 @@ $ git reset --hard ORIG_HEAD <4>
<1> Try to update from the upstream resulted in a lot of
conflicts; you were not ready to spend a lot of time merging
right now, so you decide to do that later.
-<2> "pull" has not made merge commit, so "git reset --hard"
-which is a synonym for "git reset --hard HEAD" clears the mess
-from the index file and the working tree.
+<2> "pull" has not made merge commit, so "git reset --merge"
+which is a synonym for "git reset --merge HEAD" clears the mess
+from the index file and the working tree. "git reset --hard"
+would work as well.
<3> Merge a topic branch into the current branch, which resulted
in a fast-forward.
<4> But you decided that the topic branch is not ready for public
diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
index fc56da6..9120ad5 100644
--- a/Documentation/user-manual.txt
+++ b/Documentation/user-manual.txt
@@ -1372,12 +1372,19 @@ Undoing a merge
---------------
If you get stuck and decide to just give up and throw the whole mess
-away, you can always return to the pre-merge state with
+away, you can always return to the last commit's state with
-------------------------------------------------
$ git reset --hard HEAD
-------------------------------------------------
+If you have changes that should be preserved in files not touched by
+the merge, instead use
+
+-------------------------------------------------
+$ git reset --merge HEAD
+-------------------------------------------------
+
Or, if you've already committed the merge that you want to throw away,
-------------------------------------------------
--
1.7.2.3.557.gab647.dirty
next prev parent reply other threads:[~2010-10-29 8:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-29 8:35 [RFC/PATCH 0/2] Documentation: kicking the "reset --hard" habit Jonathan Nieder
2010-10-29 8:38 ` Jonathan Nieder [this message]
2010-11-03 9:32 ` [RFC/PATCH 1/2] Documentation: suggest "reset --merge" more often Stephen Boyd
2010-10-29 8:39 ` [RFC/PATCH 2/2] Documentation: suggest "reset --keep" " Jonathan Nieder
2010-10-30 1:55 ` [RFC/PATCH 0/2] Documentation: kicking the "reset --hard" habit Matthieu Moy
2010-10-31 3:53 ` Junio C Hamano
2010-10-31 14:04 ` Matthieu Moy
2010-11-05 14:39 ` Oldest Currently Distributed Git {Re: [RFC/PATCH 0/2] Documentation: kicking the "reset --hard" habit} Drew Northup
2010-10-31 17:25 ` [RFC/PATCH 0/2] Documentation: kicking the "reset --hard" habit Ævar Arnfjörð Bjarmason
2010-11-01 20:03 ` J. Bruce Fields
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101029083836.GB26290@burratino \
--to=jrnieder@gmail.com \
--cc=bebarino@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=jnareb@gmail.com \
--cc=johan@herland.net \
--cc=srabbelier@gmail.com \
--cc=trast@student.ethz.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).