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 调用自定义头像
WP_REST_Response 返回结果类
什么是 RESTful API 的幂等性
WordPress 按自定义排序的两种方法
AIBOT 插件
Debian11 安装笔记2:编译安装PHP
Land APP 小程序
p 标签里面不能嵌套块级元素