Reputation: 1056
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?
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.
Upvotes: 5
Views: 3840
Reputation: 216
Try using:
git push origin master -f
where f
stands for forced.
Upvotes: 10