本地代码上传gitee

本文介绍了Git从初始化本地仓库、添加远程仓库到遇到push错误的整个过程。当尝试推送空目录时,Git会报错。解决方法包括创建README文件,进行add和commit操作,然后尝试push。如果遇到'Could not read from remote repository.'错误,可能是因为SSH配置问题,可以切换到HTTPS方式进行push。此外,也提供了检查权限和仓库存在的建议。
摘要由CSDN通过智能技术生成

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

$ 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’

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

解决方法:

  1. touch README
  2. git add README
  3. 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值