My solution is to merge backwards.
Instead of merging your branch into the remote "target" branch, merge that branch into yours.
git checkout my-branch
git merge origin/target-branch
You will see if there are any conflicts and can plan on how to solve them.
After that you can either abort the merge via git merge --abort
, or (if there weren't any conflicts and merge has happened) roll back to previous commit via git reset --hard HEAD~1