今天在用Git Bash上传项目至github时报错,错误如下:
$ git push -u origin master
error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/astronger/xxx.git'
错误翻译过来就是:
错误:SRC ReFSPEC主控器不匹配任何。
错误:未能将某些引用推到'xxx.git'
也就是仓库为空。
经过查阅资料,解决办法如下:
$ git add .
$ git commit -m "first"
$ git remote add origin https://github.com/astronger/xxx.git
$ git push -u origin master
把本地项目上传到Github步骤:
1、在本地创建一个版本库,先git init把它变成Git仓库;
2、把项目复制到这个文件夹里面,再通过git add . 把项目添加到仓库;
3、再通过git commit -m "注释内容" 把项目提交到仓库;
4、在Github上设置好SSH密钥后,新建一个远程仓库,通过git remote add origin https://github.com/astronger/xxx.git将本地仓库和远程仓库进行关联;
5、最后通过git push -u origin master把本地仓库的项目推送到远程仓库(也就是Github)上。