解决you have no permission to access this repo fatal: Could not read from remote repository

When I wrote a special error event
git push code today, I reported an error

-----Welcome to xxx Coding-----
----- Hi, aaa -----
you have no permission to access this repo.
fatal: Could not read from remote repository

The error prompted is very clear. Here I want to explain that my account is not called aaa. Therefore, after encountering this error, I quickly recalled what I did from yesterday (because the code can still be submitted yesterday) to today. Related to the person aaa.

I quickly thought that when I logged in to other projects today, I used SecureCRT (a tool similar to xshell) to configure a secret key (id_rsa) file of the remote server. Now think about it, the owner of this file should be called aaa.

insert image description here
After configuring the link information of SecureCRT, you can log in to the remote server directly, but when I submit the code, an error like the title appears.

Solution:
delete this link in SecureCRT, and change the name of the original file: id_rsa, you must restart the computer, and then submit the code to take effect.

Because I also have an id_rsa file in my local computer, which I generated with my own account and is used to submit the code to the warehouse for the secret-free authentication key. When someone else's secret key is imported into the computer through the SecureCRT tool, it is equivalent to overwriting the original secret key with a new secret key in the memory of the computer. As a result, the original secret key fails to pass the authentication when it is used.

The error report like the title is usually caused by the git account and incorrect email address. It is rare for mine to be caused by the id_rsa key.

View the git account and the command to modify the account:

git config --global --list
git config --global user.name
git config --global user.email

If your code has been committed, but not yet pushed, and the push failed:

git log  # 查看一下有多少commit是不符合规范的
# 如果只有最后一个commit需要修改,采用如下命令修复commit后push
git commit --amend --author="username <[email protected]>" --no-edit
# 如果本地有多个待Push的commits
git reset --soft 到之前的版本的id

Guess you like

Origin blog.csdn.net/dqchouyang/article/details/130920046