美文网首页
updates were rejected because th

updates were rejected because th

作者: dming1024 | 来源:发表于2023-03-27 22:05 被阅读0次

在使用git pushGitHub提交代码时,遇到了这样的报错

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

解决方案

参考:stackoverflow

git pull origin main

 git push origin main
#或强制push
git push -f origin main

出现二次报错

 git push -f origin main
fatal: unable to access 'https://github.com/dming1024/MSIcal.git/': Failed to connect to github.com port 443: Timed out
(base)

需要设置代理,参考文章:Github 代理

git config --global --unset http.proxy
git config --global --unset https.proxy

再进行push即可

git push -f origin main

相关文章

网友评论

      本文标题:updates were rejected because th

      本文链接:https://www.haomeiwen.com/subject/xwttddtx.html