git -c diff.mnemonicprefix=false -c core.quotepath=false revert --no-edit 33caab3d919b176504aed8ed57edcdd93fd8bc5a
error: Commit 33caab3d919b176504aed8ed57edcdd93fd8bc5a is a merge but no -m option was given.
fatal: revert failed
Completed with errors, see above.
Don't use SourceTree, you'll need to go to the git command line for this.
Undoing a merge is basically similar to undoing any other commit, but there are a few additional complications. If you are lucky enough to catch your erroneous merge before pushing it, you can just use reset --hard. If you've already pushed, or if you're following best practice and doing your commits via Pull Requests, then you'll need to use git revert. But in order to use git revert with a merge commit, you need to use the -m flag to specify which of the commit's parents to use as a baseline.
A merge commit, to Git, is just a commit with two parents. Typically one of them represents the branch you "merged into" (probably the master branch or the development branch, depending on your workflow) and the other represents the branch that you merged (such as a feature branch). But to Git, they are just parent 1 and parent 2.
The "merged into" branch represents your baseline while the "merged" branch represents the changes that you want to revert. It seems like the "merged into" branch is usually P1, but I wouldn't count on this - examine your Git history to determine for sure. If you look at the details of a commit in SourceTree or using the command
git show --pretty=%P <commit>
the first parent listed will always be P1.
Once you've determined which parent is your baseline, the command is
git revert -m <baseline> <commit>
where baseline is the number 1 or 2 (or, rarely, another number for a commit with more than two parents)
git revert -m 1 3
It is missing the parent. Explained here: http://stackoverflow.com/questions/5970889/why-does-git-revert-complain-about-a-missing-m-option
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.