转 git push 失败出现error: src refspec master does not match any.解决方案

今天写好一个demo往GitHub上传时报错

错误提示:

error: src refspec master does not match any.

error: failed to push some refs to 

找了下原因,原来是git commit -m "xxx" 时没留意,因为新装的git需要提交用户邮箱和用户名,

所以没有委托成功,本地仓库是空的,所以配置了下邮箱和用户名才成功,真是粗心不得啊!!!

*** Please tell me who you are.

Run

 git config --global user.email "you@example.com"

 git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.


分析:

1.本地git仓库目录下为空

2.本地仓库add后未commit

3.git init错误

解决方法:

1.控制面板打开文件夹选项  打开隐藏文件和文件夹显示

2.到本地仓库目录下查看是否有.git文件夹——无 则git init

3.看.git文件夹下是否有之前提交的文件——若无 则重新 git commit (如果之前git add过的话 没有就要重新 add commit)

4.新装的git要留意是否需要配置用户名和邮箱名

原文地址:https://www.cnblogs.com/python-xiakaibi/p/12982465.html