linux下git push出现“更新被拒绝,因为远程仓库包含您本地尚不存在的提交。”问题的处理

一、现象:

(base) [root@DL xbiquge]# git push -u origin master
To https://github.com/sfccl/xbiquge.git
 ! [rejected]        master -> master (fetch first)
error: 无法推送一些引用到 'https://sfccl:密码@github.com/sfccl/xbiquge.git'
提示:更新被拒绝,因为远程仓库包含您本地尚不存在的提交。这通常是因为另外
提示:一个仓库已向该引用进行了推送。再次推送前,您可能需要先整合远程变更
提示:(如 'git pull ...')。
提示:详见 'git push --help' 中的 'Note about fast-forwards' 小节。

二、原因及处理办法

1、问题出现的原因是:在网页进行了push提交动作。

2、处理办法:强制push,方法如下:

(base) [root@DL xbiquge]# git push origin +master
枚举对象: 149, 完成.
对象计数中: 100% (149/149), 完成.
Delta compression using up to 4 threads.
压缩对象中: 100% (147/147), 完成.
写入对象中: 100% (149/149), 86.90 MiB | 1.71 MiB/s, 完成.
Total 149 (delta 74), reused 0 (delta 0)
remote: Resolving deltas: 100% (74/74), done.
To https://github.com/sfccl/xbiquge.git
 + f7ac142...73353bd master -> master (forced update)

三、小结

避免这种情况的注意事项:不要通过网页向仓库提交文件。

原文地址:https://www.cnblogs.com/sfccl/p/13701145.html