git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Sverre Rabbelier" <alturin@gmail.com>
To: ff <ff@member.org>
Cc: "Miklos Vajna" <vmiklos@frugalware.org>, git@vger.kernel.org
Subject: Re: how to undo a git merge?
Date: Fri, 11 Jul 2008 20:55:43 +0200	[thread overview]
Message-ID: <bd6139dc0807111155x46a9f6acnf2d585f62342f4a6@mail.gmail.com> (raw)
In-Reply-To: <fa7d16350807111146m18b0ca9q6902c2167bfd3512@mail.gmail.com>

On Fri, Jul 11, 2008 at 8:46 PM, ff <ff@member.org> wrote:
>> For example, if you were on branch 'master' and you merged 'foo' to
>> master using 'git merge foo', and you want to revert that merge then you
>> need '-m 1'.
>
> In your example, how and why you can determine that the number 1
> represents the "foo" branch? Would "-m 2" represent the master branch?
> In your example is there any other choice for the "-m" number to use?

When you perform a merge on branch A, like so:
git checkout A  # first switch to the branch you want the merge to be on
git merge B  # now do the actual merge with the branch you want to merge with

The resulting merge commit will have the head of A as it's first
parent, and the head of B as it's second parent. With the -m switch
you can specify which parent you want to follow. If for example, you
have a three-way merge, like so ..:
git checkout A
git merge B C
.. the resulting merge commit would have A as it's first, B as it's
second and C as it's third parent. If you want to revert to the state
of C then you specify -m 3, so that the third parent is chosen. If you
performed the merge on the branch that you want to revert to, you
always specify -m 1. If you did this ..:
git checkout B
git merge A
.. and then you want to restore the state of branch A, you use '-m 2'.

-- 
Cheers,

Sverre Rabbelier

  parent reply	other threads:[~2008-07-11 18:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-11 16:16 how to undo a git merge? ff
2008-07-11 16:19 ` Miklos Vajna
     [not found]   ` <fa7d16350807111107o40c5cbb5xc06c3c56b16b7499@mail.gmail.com>
2008-07-11 18:14     ` Miklos Vajna
2008-07-11 18:46       ` ff
2008-07-11 18:53         ` Miklos Vajna
2008-07-11 18:55         ` Sverre Rabbelier [this message]
2008-07-11 17:13 ` Jakub Narebski
     [not found]   ` <fa7d16350807111108y3a8a7c3di19598a56dbbcdc15@mail.gmail.com>
2008-07-11 18:36     ` Jakub Narebski

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=bd6139dc0807111155x46a9f6acnf2d585f62342f4a6@mail.gmail.com \
    --to=alturin@gmail.com \
    --cc=ff@member.org \
    --cc=git@vger.kernel.org \
    --cc=sverre@rabbelier.nl \
    --cc=vmiklos@frugalware.org \
    /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).