您的位置:首页 > 其它

Git常见错误与操作:error: src refspec master does not match any解决办法

2018-06-15 20:58 861 查看

Git常见错误与操作:error: src refspec master does not match any解决办法引起该错误的原因是目录中没有文件,空目录是不能提交上去的解决办法:

[html] view plain copy
  1. $ touch README  
  2. $ git add README  
  3. $ git commit –m’first commit’  
  4. $ git push origin master  

实际上

[html] view plain copy
  1. $ git init  

这一步之后创建了一个名为.git的文件夹,不过它在默认状态下是隐藏的,系统将隐藏文件夹显示出来,可以看到有这样一个文件夹。
github上传项目方法:
http://www.oschina.net/question/159132_86728
在你的电脑上装好git大致流程是:

[html] view plain copy
  1. 1、 在github上创建项目  
  2. 2、 使用$ git clone https://github/xx账号/xx项目.git克隆到本地  
  3. 3、 编辑项目  
  4. 4、 $ git add .(将改动添加到暂存区)  
  5. 5、 $ git commit –m ”提交说明”  
  6. 6、 $ git push origin 将本地更改推送到远程master分支  

这样你就完成了向远程仓库的推送如果在github的remote上已经有了文件,会出现错误。此时应当先pull一下,即:

[html] view plain copy
  1. $ git pull origin master  

然后再进行:

[html] view plain copy
  1. $ git push origin master  
阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: