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

本文档属于入门指南指南的一部分。您可以在此处查看完整指南:如何在 Stackhero 上快速开始使用 PHP

👋 欢迎查阅 Stackhero 文档!

Stackhero 提供专为高效、可靠部署打造的 PHP 云平台

  • 只需一次简单的 git push,即可在几秒钟内部署您的 PHP 应用到生产环境。
  • 支持自定义域名,HTTPS 证书自动配置,无需手动操作。
  • 依托自动备份一键更新以及清晰、可预测的定价,Stackhero 为您处理所有细节,让您专注于代码开发。
  • 基于专为您的应用打造的私有专用基础设施,享受卓越的性能安全性

让您的工作流程更高效,节省宝贵时间。只需几分钟,即可开始体验 Stackhero 的 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