本文主要是介绍遇到一个git的大坑 src refspec master does not match any error: failed to push some refs to,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
今天本来想把内容上传到git仓库去,但是折腾了好久一直报错。
错误信息是这样的。
error: src refspec master does not match any error: failed to push some refs to
这个错误其实是很常见的错误,但是一直没有解决,试了很多方法,结果都不行。
这个问题的常见原因有:
1.本地git仓库目录下为空
2.本地仓库add后未commit
3.git init错误
4.没有先进行git pull
但是我的都不是这些原因。我的问题在于,我的这个本地项目早就存在了,但是一直没有使用git,于是我想直接在项目中创建git仓库,直接git init
,就是这种方式导致的。
常规方式是:创建文件夹->git init -> git add . -> git commit -> git push.
我的方式是:已有陈旧项目->git init -> git add . -> git commit -> git push.
因此,导致我一直失败,所以,只需要采用常规方式即可解决问题!
更新
最新的一个问题是,现在github的默认分支为main,但是,我一直认为是master,所以,在提交时,需要提交到main,而不是master。
使用:git push origin main
,即可。
这篇关于遇到一个git的大坑 src refspec master does not match any error: failed to push some refs to的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!