Linux系统下解决使用github提示Please make sure you have the correct access rights and the repository exists的错误

在克隆代码时,为什么会遇到Please make sure you have the correct access rights and the repository exists的报错呢?原因在于你的GitHub没有设置好。具体怎么解决呢?按以下步骤进行。

1. 打开终端,输入:

git config --global user.name "yourname"

git config --global user.email"your@email.com"

请注意,这里的"yourname"一定一定要和你的Github上的username 相对应,注意是一定!比如我的是“jianglinzhou" 就不能写成"jianglin",写错了的话,下面的工作全白搭。

2. 删除旧配置文件

继续在终端输入:

sudo rm -rf /home/zjl/.ssh/

3. 生成配置文件 

继续在终端输入:

ssh-keygen -t rsa -C "your@email.com"(请填你设置的邮箱地址)

出现: 

根据提示直接按下回车即可,之后系统会自动在/home/zjl/.ssh文件夹下生成两个文件,id_rsaid_rsa.pub

4. 打开id_rsa.pub文件

可能无法打开,那就先传到windows再打开,并全选复制

5.  登记Key

登录Github,并进入设置,找到ssh an GPG keys,选择添加SSH Key,将刚才复制好的公共密匙黏贴到此处,最后点击Add_ssh_key保存即可

6.  检验操作是否成功

终端输入:

ssh -T git@github.com

出现hi则表示成功,其余都是不好意思,再来一次。

参考: (不懂音乐的欣赏者的博客

### GitHub Access Rights and Repository Existence Solution When encountering issues related to GitHub access rights or confirming whether a repository exists, it typically involves checking authentication credentials, permissions, and network configurations. Below are some detailed approaches to address these problems: #### Authentication Verification Ensure that the correct personal access token (PAT) or OAuth token is being used when accessing private repositories through APIs or Git commands[^1]. If using an API call such as `axios`, include headers with proper authorization tokens. For example: ```javascript const axios = require('axios'); async function checkRepositoryExistence(owner, repoName, token) { try { const response = await axios.get(`https://api.github.com/repos/${owner}/${repoName}`, { headers: { Authorization: `token ${token}` } }); console.log(response.data); // Repository data if accessible. } catch (error) { if (error.response && error.response.status === 404) { console.error("The specified repository does not exist."); } else if (error.response && error.response.status === 403) { console.error("Access denied due to insufficient permissions."); } else { console.error(error.message); } } } ``` This script checks both existence and accessibility by handling HTTP status codes appropriately[^2]. #### Network Configuration Check If there’s no internet connection or firewall restrictions block communication between your system and GitHub servers, ensure all necessary ports (`HTTPS` port `443`) remain open for external communications. Additionally, consider configuring SSH keys instead of relying solely on HTTPS-based URLs since they provide more secure connections without exposing sensitive information repeatedly during operations like cloning repos etc. #### Debugging Tips Use verbose output options provided within command-line tools while interacting directly via terminal sessions; e.g., appending `-v` flag after git fetch/pull requests helps identify where exactly things might go wrong at each stage before reaching final failure points. ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值