Re: how to undo a git merge?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 11, 2008 at 8:46 PM, ff <ff@xxxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux