how to undo a git merge?

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

how to undo a git merge?

From: ff <hidden>
Date: 2016-06-15 22:44:55

Hello,

I'm a git lover with a question.

I have two git branches that stem from the same exact master branch.
Many commits happened independently on these two branches overtime.
Then, I inadvertently did a merge from one branch into another. The branch
where I merged into now has mixed commits, and also a commit for the merge
itself. I then had more commits added to the branch that I merged into.

Now I would like to revert the merge... what is the best way of doing that?
I would like very much to use something like git-revert <merge_commit_id>
But that does not seem to work.

Any help/pointers of an example illustrating solution to this case
would be greatly
appreciated!

Regards,

-- ff@member.org

Re: how to undo a git merge?

From: Miklos Vajna <hidden>
Date: 2016-06-15 22:44:55

On Fri, Jul 11, 2008 at 12:16:15PM -0400, ff [off-list ref] wrote:
Now I would like to revert the merge... what is the best way of doing that?
I would like very much to use something like git-revert <merge_commit_id>
But that does not seem to work.
git revert has a '-m' option to revert merges. See the manpage.
Any help/pointers of an example illustrating solution to this case
would be greatly
appreciated!
Actually if you just did that merge by accident, then probably you want
'git reset --hard HEAD^', not git revert, I think.

Re: how to undo a git merge?

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:44:55

ff [off-list ref] writes:
I have two git branches that stem from the same exact master branch.
Many commits happened independently on these two branches overtime.
Then, I inadvertently did a merge from one branch into another. The branch
where I merged into now has mixed commits, and also a commit for the merge
itself. I then had more commits added to the branch that I merged into.

Now I would like to revert the merge... what is the best way of doing that?
I would like very much to use something like git-revert <merge_commit_id>
But that does not seem to work.
If you have published history, then the only sane option is
"git revert -m".  If you haven't published history, you can
try "git rebase --interactive".

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help