github上传文件遇到的问题,记录一下,遇到不止一次了

本文讲述了遇到'origin does not appear to be a git repository'错误时,如何通过SSH连接、初始化远程仓库、添加远程仓库和解决权限问题的详细步骤,包括git clone、git init、git remote操作和SSH警告的处理。

1.最好使用ssh连接,不知道是不是https的问题,会报错:

fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

然后查看$ git remote -v,则出现
 

origin  master (fetch)
origin  master (push)

 而正确的格式应为

origin  git@github.com:githubName/仓库名.git (fetch)
origin  git@github.com:githubName/仓库名.git (push)

这时应该

git init
git remote rm origin
git remote add origin git@github.com:githubName/仓库名.git(注:ssh链接)

这样就好了!

2.在git commit -m "仓库名"后报错:

On branch master
nothing to commit, working tree clean

这是因为git add . 将所有文件添加到缓存区,git commit -m "仓库名"将文件提交到本地仓库,然后再次git commit -m "仓库名"反复提交重复的东西就会报这个错误。所以这时只需

git push origin master

就好啦!!!

记录我的完整流程!对我必成功,其他人的流程不知道为啥不行

git clone git@github.com:githubName/仓库名.git
git init
git remote add origin git@github.com:githubName/仓库名.git
git add .
git commit -m "备注"
git push origin master

更新:报错

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s.
Please contact your system administrator.
Add correct host key in /c/Users/NaTingting/.ssh/known_hosts to get rid of this message.
Offending RSA key in /c/Users/NaTingting/.ssh/known_hosts:1
RSA host key for github.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

删除user/.ssh/目录下的known_hosts文件,再重新输入命令就好了。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值