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

本文件是入门指南指南的一部分。您可以在这里查看完整指南:了解如何在 Stackhero 上快速且安全地部署 Node.js 服务

👋 欢迎来到 Stackhero 文档!

Stackhero 提供即开即用的 Node.js cloud 环境,助您加速开发进程:

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

节省时间,降低运维负担:只需几分钟,您的应用即可在 Stackhero 的 Node.js 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
(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