在使用git push
向GitHub
提交代码时,遇到了这样的报错
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.
解决方案
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
网友评论