如何应用 git 恢复?

发布于 2024-11-08 13:35:54 字数 450 浏览 0 评论 0原文

我正在开发 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人海汹涌 2024-11-15 13:35:54

(看起来你不仅重置了一些修订,而且还在本地创建了一个新的提交,否则错误将只是“已经是最新的”或类似的内容。你可以使用 git 检查这一点获取 origin,然后 gitk --all。)

如果您确定只想丢弃部署服务器的 master 上的额外提交,您可以用力推动:

 git push --force origin 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 then gitk --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:

 git push --force origin master

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文