ERROR: Repository not found. fatal: 无法读取远程仓库。 然后再次输入:remote add origin git@github.com:duoduosel...

本文讲述了将练习作业上传到Github时出现的错误。因上传命令中项目名错误,导致推送失败。给出了解决办法,如删除关联的远程库,若仍报错则修改gitconfig文件内容,删除其中[remote “origin”]一行。

把练习作业上传到 Github过程中出现的错误
在这里插入图片描述上传命令git remote add origin git@github.com:duoduosell/rails101-1.git本应该是rails101,名字错了,导致:git push -u origin master错误返回:ERROR: Repository not found.fatal: 无法读取远程仓库。
然后再次输入:remote add origin git@github.com:duoduosell/rails101.git
fatal: 远程 origin 已经存在先 git remote -v 查看远程库信息:

在这里插入图片描述

解决办法如下:
1、先输入$ git remote rm origin(删除关联的origin的远程库)
2、再输入$ git remote add origin git@github.com:(github名)/(git项目名).git 就不会报错了!
3、如果输入$ git remote rm origin 还是报错的话,error: Could not remove config section ‘remote.origin’. 我们需要修改gitconfig文件的内容
4、找到你的github的安装路径,我的是C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\etc5、找到一个名为gitconfig的文件,打开它把里面的[remote “origin”]那一行删掉就好了!

### ### Git Clone Failed with Error 'remote: Repository not found' and 'fatal: Authentication failed' – How to Fix 当用户尝试使用 `git clone` 命令克隆 GitHub 仓库时,如果遇到 `remote: Repository not found` 和 `fatal: Authentication failed` 错误,通常涉及以下几个原因:仓库不存在、认证失败或访问方式配置错误。 #### 1. **仓库不存在(Remote: Repository not found)** 如果提示 `remote: Repository not found`,可能的原因包括: - 仓库名称或用户名拼写错误。 - 仓库已被删除或迁移。 - 使用 HTTPS 克隆时未正确提供认证信息。 建议检查仓库地址是否完整正确,例如: ```bash git clone https://github.com/username/repository.git ``` 如果仓库地址无误但仍提示未找到,应确认仓库是否对当前用户开放访问权限,或是否为私有仓库但未授权访问[^1]。 #### 2. **认证失败(Authentication failed)** 使用 HTTPS 克隆时,若提示 `Authentication failed`,通常是因为未正确提供用户名和密码,或 GitHub 已停用密码认证,改用 Personal Access Token (PAT) 进行身份验证。 解决方法是使用带有 Token 的克隆命令: ```bash git clone https://<your_token>@github.com/username/repository.git ``` 其中 `<your_token>` 是在 GitHub 账户中生成的 Personal Access Token。该方式适用于 HTTPS 协议下的认证访问[^1]。 #### 3. **使用 SSH 避免认证问题** 为避免 HTTPS 的认证问题,建议使用 SSH 协议克隆仓库。前提是在本地生成并添加了 SSH 密钥到 GitHub 账户。生成密钥并添加到 GitHub 的命令如下: ```bash ssh-keygen -t rsa -C "your_email@example.com" eval $(ssh-agent -s) ssh-add ~/.ssh/id_rsa ``` 随后将 `~/.ssh/id_rsa.pub` 中的公钥内容添加到 GitHub 的 SSH Keys 设置中,并验证连接: ```bash ssh -T git@github.com ``` 验证成功后即可使用 SSH 克隆仓库: ```bash git clone git@github.com:username/repository.git ``` 该方法无需每次输入用户名和密码,适用于频繁操作 GitHub 仓库的用户[^3]。 --- ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值