遇到一个git的大坑 src refspec master does not match any error: failed to push some refs to
今天本來想把內(nèi)容上傳到git倉庫去,但是折騰了好久一直報錯。
錯誤信息是這樣的。
error: src refspec master does not match any error: failed to push some refs to這個錯誤其實是很常見的錯誤,但是一直沒有解決,試了很多方法,結(jié)果都不行。
這個問題的常見原因有:
1.本地git倉庫目錄下為空
2.本地倉庫add后未commit
3.git init錯誤
4.沒有先進行g(shù)it pull
但是我的都不是這些原因。我的問題在于,我的這個本地項目早就存在了,但是一直沒有使用git,于是我想直接在項目中創(chuàng)建git倉庫,直接git init,就是這種方式導(dǎo)致的。
常規(guī)方式是:創(chuàng)建文件夾->git init -> git add . -> git commit -> git push.
我的方式是:已有陳舊項目->git init -> git add . -> git commit -> git push.
因此,導(dǎo)致我一直失敗,所以,只需要采用常規(guī)方式即可解決問題!
更新
最新的一個問題是,現(xiàn)在github的默認(rèn)分支為main,但是,我一直認(rèn)為是master,所以,在提交時,需要提交到main,而不是master。
使用:git push origin main,即可。
總結(jié)
以上是生活随笔為你收集整理的遇到一个git的大坑 src refspec master does not match any error: failed to push some refs to的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一款高颜值的 SpringBoot+JP
- 下一篇: 快速接入 GitHub、QQ 第三方登录