Bitbucket git reset

一个人想着一个人 提交于 2019-12-06 03:04:16

问题


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?


回答1:


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.




回答2:


git reset doesn't delete commits; if that's your intent. It resets the current working tree (staged changes to be committed) on your local machine.



来源:https://stackoverflow.com/questions/19249572/bitbucket-git-reset

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!