PHP: 處理錯誤 "failed to push some refs to '[...]'"

本文件是快速開始指南的一部分。請在此處查看完整指南:如何在 Stackhero 上開始使用 PHP

👋 歡迎來到 Stackhero 文件中心!

Stackhero 提供專為快速且可靠部署設計的 PHP cloud 平台:

  • 只需一個簡單的 git push,即可在數秒內部署您的 PHP 應用程式到生產環境。
  • 可使用您自己的網域名稱,並為您自動設定 HTTPS 憑證,全程無需手動操作。
  • 享有自動備份一鍵更新,以及清楚、可預測的收費模式。Stackhero 為您處理這些細節,讓您能專注於開發程式碼。
  • 在專為您的應用程式打造的專屬私有基礎架構上,獲得強大的效能安全性

讓您的工作流程更順暢,節省寶貴時間。只需幾分鐘,即可開始體驗 Stackhero 的 PHP cloud hosting

如果在部署時遇到如下錯誤:

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