Bitbucket git重置 [英] Bitbucket git reset

查看:146
本文介绍了Bitbucket git重置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经完成了这个git命令:

I've done this git commands:

git reset --hard hash
git push -f

所有本地都很好,'hash'提交后我没有看到任何提交。推之后一切都很好,没有错误,但在我的仓库(Overview)的Bitbucket主面板上,最后一次提交仍然存在。我不明白,我是否重置远程存储库?

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?

推荐答案

问题是您的SHA没有更改,所以Git并未真正更新BitBucket上的远程。重置后的历史记录仍然存在,您可以执行 git pull ,您的本地回购将获得所有后续提交。

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.

完成 git reset --hard HASH 后,执行 git reset HEAD〜(note :这是一个软复位)然后重新发送更改。这将为提交生成一个新的SHA,当你强制推送你的更改时,BitBucket上的树应该按照你的预期更新。

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.

警告
这正在改变历史,如果还有其他人从回购中获利,这将会造成麻烦。这应该不是一个正常的工作流程来取消远程分支上的更改,您应该使用 git revert

这篇关于Bitbucket git重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆