Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bitbucket git reset

Tags:

git

bitbucket

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?

like image 927
malcoauri Avatar asked Oct 02 '22 18:10

malcoauri


1 Answers

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.

like image 188
Schleis Avatar answered Oct 13 '22 10:10

Schleis