Re: how to undo a git merge?
- From
- Sverre Rabbelier <alturin@gmail.com>
- Date
- Jul 11, 2008, 18:55 UTC
- Message-ID
- <bd6139dc0807111155x46a9f6acnf2d585f62342f4a6@mail.gmail.com>
- In-Reply-To
- <fa7d16350807111146m18b0ca9q6902c2167bfd3512@mail.gmail.com>
On Fri, Jul 11, 2008 at 8:46 PM, ff <ff@member.org> wrote:
Show 7 quoted lines
>> 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