I've done this git commands:
git reset --hard hash
git push -f
All was good locally, I don't see any commits after 'hash' commit. All was good after pushing too, there were no errors, but on Bitbucket main panel of my repository (Overview) last commits still are. And I don't understand it, have I reset remote repository or not?
The problem is that your SHA's have not changed so Git doesn't really update the remote on BitBucket. The history after where you reset still exists, you would be able to do git pull
and your local repo would get all the later commits.
After doing the git reset --hard HASH
, do a git reset HEAD~
(note: this is a soft reset) Then recommit the changes. This will generate a new SHA for the commit and when you force push your changes, the tree on BitBucket should be updated as you expect.
WARNING
This is changing history and if there are others that have pulled from the repo, it will cause trouble. This should not be a normal workflow for undoing changes on a remote branch, you should use git revert
.
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