Git: Undo a merge solution

# you are on the dev branch
git checkout master
git merge dev 
# here you've merged the dev branch into master but actually you wanted to perform a --no-ff merge
git reset --hard origin/master to undo the above merge: reset the master branch to the pre-merge state
git merge --no-ff -m 'my custom merge message' dev # now you can perform the merge you actually wanted

To undo an already pushed merge, you have to "git reset --hard 'the preceding commit ID of your last push to the master branch'" and repush the newly created commit using the -f flag.


Popular posts from this blog

Tuning ext4 for performance with emphasis on SSD usage

How to fix: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu