I pushed a commit to the remote repository and I want to undo that commit.
To undo the commit in my local repository I usedgit reset --hard prev_commit_hash
(By the way, is this the proper way to do that?)
Then I tried to push, and failed, because the tip of my current branch is behind its remote counterpart, as I expected.
The question is: What is the proper way to perform a hard/forced push?
Edit:
I viewed some of the other similar questions asked, but they were a little old.
The suggested solution was using git revert
. And I saw that recently users commented that this solution is not working for them.
Try using:
git push origin master -f
where f
stands for forced.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With