Git提交时提示“Please make sure you have the correct access rights and the repository exists.”的解决方法
- 在需要提交的项目根目录下,输入以下命令来设置名字和邮箱:
git config --global user.name "你的名字"
git config --global user.email "你的邮箱"
1
2
2
该处填写的名字和邮箱为github上的用户名和邮箱
- 删除
.ssh
文件下的know_hosts
- 生成公钥认证所需的公钥和私钥文件
ssh-keygen -t rsa -C "你的名字/你的邮箱"
1
之后会出现以下内容:
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
/c/Users/Administrator/.ssh/id_rsa already exists.
Overwrite (y/n)? y(输入y)
Enter passphrase (empty for no passphrase):(回车)
Enter same passphrase again:(回车)
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
此时再.ssh
文件夹下生成了两个文件,id_rsa
和id_rsa.pub
, 用文本编辑器打开id_rsa.pub
, 将内容复制到下面
- 在Git中输入以下命令来检测是否与github连接成功:
ssh -T git@github.com
1
编辑 (opens new window)
上次更新: 2022/05/22, 23:59:38