使用git push时出现error: src refspec master does not match any. 是什么原因

使用git push是,采用以下步骤:

git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/focusor/focusor.github.io.git
git push -u origin master

产生如下错误:

error: src refspec master does not match any. 
error: failed to push some refs to "xxxxxxx"

然后用如下方法解决了:

git add .
git commit -m "write your meaaage"

之后push就成功了,具体原因是什么呢?

阅读 76.8k
5 个回答

这种错误一般是因为push的时候暂存区没有文件,确认下add的README.md存不存在

也可能是你分支不正确

clipboard.png

新手上路,请多包涵

git add . 会监控工作区的状态树,使用它会把工作时的所有变化提交到暂存区,包括文件内容修改(modified)以及新文件(new),但不包括被删除的文件.

新手上路,请多包涵

亲测可用
image.png

推荐问题