Undo a Git merge that hasn't been pushed yet
Undo a Git merge that hasn’t been pushed yet
reflog
The first step would be to use reflog to find the commit right before the merge:
reset
Once you find the commit that you want to revert back to, use the reset command
1
| $ git reset --hard <commit-hash>
|
close behind the merge
If the commit you want to get back to is only one behind HEAD, then you can instead use ORIG_HEAD as a shortcut in the reset command:
- With modern Git, you can:
- Older syntax:
- Old-school:
1 2 3 4 5
| $ git reset --hard
or
$ git reset --hard ORIG_HEAD
|