Git push 错误:Updates were rejected because the remote contains work that you do not have locally

执行 git push -u origin main 报错:

git push -u origin main
To https://gitee.com/test/test.git
 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to 'https://gitee.com/soushenji/expressjs-docs.git'
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.

 

由于远程包含本地没有的工作,更新被拒绝。这通常是由另一个存储库推送到同一个ref引起的。所以应该提前执行 git pull 一下。

执行一下 git pull origin main --allow-unrelated-histories 即可。

 

如果你确信你的更改与远程仓库中的更改不会有冲突,你可以使用强制推送,但这种做法通常不推荐,因为它会覆盖远程仓库中的提交:

git push origin master --force

 

修改时间 2024-05-12

声明:本站所有文章和图片,如无特殊说明,均为原创发布。商业转载请联系作者获得授权,非商业转载请注明出处。
随机推荐
WordPress 侧边栏小工具
Node.js test 模块
Wordpress 主样式表(style.css)
WordPress 用户信息
WordPress 自定义模板路径
JavaScript screen对象
WordPress 函数 get_categories() 获取所有分类
版权相关