如何应用 git 恢复?
我正在开发 git 部署服务器。我必须将我的本地头重置回一些提交,现在我试图让服务器恢复同步。我收到此错误...
! [rejected] master -> master (non-fast-forward) error: failed to push some refs to server
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
当我拉动它时,只是将我的本地存储库放回到恢复之前...
谢谢!
I'm working on a git deploy server. I had to reset my local head back a few commits and now im trying to get the server back in sync. I get this error...
! [rejected] master -> master (non-fast-forward) error: failed to push some refs to server
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
When I pull it just puts my local repo back before the revert...
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(看起来你不仅重置了一些修订,而且还在本地创建了一个新的提交,否则错误将只是“已经是最新的”或类似的内容。你可以使用
git 检查这一点获取 origin
,然后gitk --all
。)如果您确定只想丢弃部署服务器的
master
上的额外提交,您可以用力推动:用力推动通常意味着您正在以一种可能对项目中的任何合作者造成问题的方式重写历史,但我认为由于这只是您为了部署而推送的服务器,因此它不是人们从中克隆的服务器。然而,如果我的假设是错误的,你应该重新考虑一下。
(It looks as if you've not only reset back a few revisions, but also create a new commit locally, since otherwise the error would just be "already up to date" or something similar. You can check this with
git fetch origin
and thengitk --all
.)If you're sure that you want to just discard the extra commits on the deploy server's
master
, you can do a force push with:Force pushing usually means that you're rewriting history in a way that may be problematic for any collaborators on the project, but I assume that since this is just a server that you push to in order to deploy, it's not one that people are cloning from. However, if my assumption is wrong, you should rethink this.