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

此文件屬於入門指南指南的一部分。請在此處查看完整指南:如何在 Stackhero 上開始使用 PHP

👋 歡迎來到 Stackhero 文檔!

Stackhero 提供一個即用型的 PHP cloud 解決方案,帶來多種好處,包括:

  • 只需一個簡單的 git push,即可在幾秒鐘內 部署您的應用程式。
  • 使用您自己的域名,並享受 HTTPS 證書的自動配置,以增強安全性。
  • 享受自動備份一鍵更新,以及簡單、透明且可預測的定價,讓您高枕無憂。
  • 得益於專用的私人 VM,獲得最佳的性能和強大的安全性

節省時間簡化您的生活:只需 5 分鐘即可嘗試 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