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

本文档属于Node.js 快速部署指南指南的一部分。您可以在此处查看完整指南:快速安全地在 Stackhero 上部署 Node.js。

👋 欢迎查阅 Stackhero 文档!

Stackhero 提供即开即用的 Node.js 云环境,助您高效开发:

  • 只需一次简单的 git push,几秒钟即可部署到生产环境,无需额外工具或手动配置。
  • 支持自定义域名,并自动配置 HTTPS 证书,让您的应用安全无忧,无需额外设置。
  • 自动备份、一键升级以及可预测的定价,让您专注于功能开发,基础设施交由 Stackhero 托管。
  • 基于专属私有基础设施,保障性能稳定与高水平安全。

节省时间,降低运维负担:只需几分钟,您的应用即可在 Stackhero 的 Node.js 云主机 上运行。

如果出现如下错误:

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
(e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

说明您的本地仓库与远程仓库不同步。您可以强制推送:

git push -f stackhero main