PHP: 处理 "failed to push some refs to '[...]'" 错误

本文件是快速入门指南的一部分。您可以在这里查看完整指南:如何在 Stackhero 上开始使用 PHP。

👋 欢迎查阅 Stackhero 文档!

Stackhero 提供托管型 PHP 主机服务,专为实现快速、可靠的部署而设计:

  • 只需一次简单的 git push,即可将您的 PHP 应用快速部署到生产环境。
  • 支持自定义域名,自动为您配置 HTTPS 证书,无需手动操作。
  • 享受自动备份、一键升级以及清晰、可预测的定价。Stackhero 会为您处理这些细节,让您专注于代码开发。
  • 基于专为您的应用打造的私有专属基础设施,性能与安全性均有保障。

让您的工作流程更高效,节省宝贵时间。 只需几分钟,即可开始体验 Stackhero 针对 Laravel 和 Symfony 的 PHP 托管服务。

如果部署时遇到如下错误:

error: failed to push some refs to '[...]'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

这表示远程 Git 仓库有您本地没有的更改。如果您确定要用本地版本覆盖远程内容,可以强制推送:

git push -f stackhero main