How to revert a merge that has been pushed to origin? Use Revert. After merging my develop branch into the main branch i realized i didn’t want to release the code i just merged. But it was already pushed to origin. What do do?
The steps to revert a merge, in order, are:
- git log OR git reflog (to find the last commit ID)
- git reset –merge (to revert to the commit you specify)
Revert to the Commit :
We can use this hash to revert the merge commit with the git reset –merge command:
git reset --hard 'ac854d0'
git clean -f -d
git push -f
This command resets our repository to the state it was at in the a9fdeb5 commit on the main branch.