git上传文件error:src refspec master does not match any

本地仓库使用如下命令初始化:

$ git init

之后使用如下命令添加远程库:

$ git remote add origin git@github.com:hahah/ftpmanage.git

然后使用

$ git push -u origin master

出现如下错误:

error: src refspec master does not match any. error: failed to push some refs to 'git@github.com:hahaha/ftpmanage.git'

引起该错误的原因是,目录中没有文件,空目录是不能提交上去的

解决方法:

touch README

git add README

git commit -m 'first commit'

最后执行$ git push -u origin master

如果出现这个错误:Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

可能是暂存区没有文件,通过git add操作可以添加到暂存区以便commit。

运行 $git add .成功把文件存到暂存区

接下来继续运行$git commit -m 'first commit'将暂存区的代码提交到本地仓库

最后成功push到GitHub上面 $git push origin master

如果push中出现如下错误:: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

.这可能是是由于你的git地址采用了ssh方式,切换为https方式

在终端中输入:

$ git remote set-url origin https://github.com/YourUserName/YatouTest00123.git

然后再push一下

$git push -u origin master

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • git常用命令 GIT常用命令备忘:http://stormzhang.com/git/2014/01/27/gi...
    新篇章阅读 8,681评论 1 26
  • Git使用教程:https://blog.csdn.net/tgbus18990140382/article/de...
    SkTj阅读 2,847评论 1 11
  • 1.git的安装 1.1 在Windows上安装Git msysgit是Windows版的Git,从https:/...
    落魂灬阅读 12,745评论 4 54
  • 1. GIT命令 git init在本地新建一个repo,进入一个项目目录,执行git init,会初始化一个re...
    江边一蓑烟阅读 848评论 0 0
  • 1. 安装 Github 查看是否安装git: $ git config --global user.name "...
    Albert_Sun阅读 13,751评论 9 163