git命令clone报错:remote: The project you were looking for could not be found

报错

remote: The project you were looking for could not be found.

原因

本地 Git 默认使用的是上一个使用的用户名密码,如果 clone 项目允许的用户名 / 密码 与当前默认用户名 / 密码 不一致(或者当前用户无权限),就会报错 The project you were looking for could not be found

解决办法

1. http 形式克隆

如果 clone 的是 http 方式,那么在克隆的项目路径上添加有权限的用户名,如会弹出密码框,输入对应的密码,就可以克隆了。

https://gitee.com/strive_xgf/base-code-day.git
// 新增有权限的用户名到路径前
https://有权限的用户名@gitee.com/strive_xgf/base-code-day.git

2. ssh 形式克隆

需要生成 SSH 公钥,并将生成的公钥添加到远程仓库的 SSH 公钥上去。

2.1 点击仓库上的SSH复制SSH地址
在这里插入图片描述
2.2 打开Git Bash Here窗口
输入命令ssh-keygen -t rsa -C “ssh地址值 / 自定义名称”来生成对应本地数据的ssh的key值,然后回车,遇到(Y/N)输入Y,其它回车就行
在这里插入图片描述
2. 3 获取对应本地仓库的ssh公钥值
输入 cat ~/.ssh/id_rsa.pub 命令获取ssh的key值
在这里插入图片描述
2.4 将得到的ssh公钥复制,将其添加到我们的远程仓库 gitee 的SSH公钥上去

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
秘钥生成成功:
在这里插入图片描述
这时候就可以直接使用 clone 命令克隆了。

猜你喜欢

转载自blog.csdn.net/qq_40542534/article/details/116146302
今日推荐