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

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

$ git init

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

$ git remote add origin git@github.com:gitee用户名/仓库名.git

然后使用

$ git push -u origin master

出现如下错误:

error: src refspec master does not match any

error: failed to push some refs to 'gitee.com:gitee用户名/仓库名.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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值