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
Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot