Hike Nalbandyan Hike Nalbandyan - 1 month ago 6x
Git Question

Git: How to perform hard push

I pushed a commit to the remote repository and I want to undo that commit.

To undo the commit in my local repository I used

git 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?


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.