I have accidentally merged the wrong branch into master, and pushed to origin.
The problem is, that i have resetted the masterbranch to the last before commit-hash with git reset --hard xxx
and also the origin with git push origin master --force
but now the merge-commit is always there.
The better solution is to use git revert -m 1 <merge-commit>
, but I have not :/
Now, from this state, how can i undo the merge an clear the history? Maybe, merge again and revert!?
you are doing
git log --oneline
see the commits before the merge
then just reverting to that commit before merging WITHOUT any reseting!!! After push again to origin as a new commit.
Reverting means that your next snapshot would be equally the same as the one before merging, but your mistaken merge-commit will be saved in overall commits history - which is better to leave there. Avoid git reset hard as much as possible.