git github 相信大家都很熟悉,在使用的过程中难免会出现一些问题,更何况我这样的经常换设备以及虚拟机的用户,经常会遇到git的各种问题,下面简单记录一下曾经出现过的问题以及解决的方法,可能部分解决的方法不是很正规,但是不管怎么说在本人的环境下都能回归到正常状态,所以,请不要打击我们小白的学习的劲头^_^。

一、在进行git clone的时候,出现如下所示的问题

Cloneing into 'xxxx'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解决方案:

1、使用指令测试一下githubssh是否配置成功, -T不显示终端,只显示连接成功信息

$ ssh -T git@github.com

输出:
git@github.com: Permission denied (publickey).

2、配置一下用户名和邮箱

$ git config --global user.name "username"
$ git config --global user.email "email@example.com"

3、此时可以尝试一下git clone指令,本人测试实际效果还是和之前的问题是一致的,所以,继续往下操作

$ ssh -v git@github.com

 

找到他尝试的.ssh的路径是这个路劲,然后好奇看了一下这个文件夹下有什么文件

天啦,里面竟然没有id_rsa和id_rsa.pub文件,在查找一下这个文件,用Everything工具查找一下

然后将包含id_rsa的这个.ssh的这个文件夹直接替换那个没有id_rsa的文件,然后在测试

然后再进行clone操作

完成,之后的git push pull等操作均可以正常运行。

二、git clone出现下面的问题

Cloneing into 'xxxx'...
sign_and_send_pubkey: signing failed: agent refused operation
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解决方案:

1、使用指令测试连接

$ ssh -T git@github.com

输出:
sign_and_send_pubkey: signing failed: agent refused operation

Permission denied (publickey).

2、设置用户名和邮箱

$ git config --global user.name "username"
$ git config --global user.email "email@example.com"

3、将SSH Key添加到ssh-agent

$ ssh-agent -s

输出:

SSH_AUTH_SOCK=/tmp/ssh-5JYIIgdzHvTM/agent.34213; export SSH_AUTH_SOCK;
SSH_AGENT_PID=34214; export SSH_AGENT_PID;
echo Agent pid 34214;

4、使用指令 ssh-add 将专用密钥添加到ssh-agent的高速缓存中,默认路劲

$ ssh-add
输出:
Identity added: /home/yourname/.ssh/id_rsa (/home/yourname/.ssh/id_rsa)

4、再次测试连接

$ ssh -T git@github.com
输出:
Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.

5、然后在进行git clone,即可成功,后续操作也没有任何问题。

三、git clone 出现输入密码,并且然后Permission Denied (publickey)问题

解决方案:

可知先直接使用ssh-add ~/.ssh/id_rsa把专用密钥(private and public keys)添加到 ssh-agent 的高速缓存中

其中 ~/.ssh/id_rsa 的根据个人不同做适当的更改

如果还是不好用,则可以按照下面的步骤继续进行。

1、设置用户名和邮箱

$ git config --global user.name "username"
$ git config --global user.email "email@example.com"

2、创建一个 SSH key

ssh-keygen -t rsa -C "email@example.com"

如果之前已经存在ssh key,那么会提示是否进行覆盖,此处输入 y

3、把专用密钥(private and public keys)添加到 ssh-agent 的高速缓存中

$ ssh-add ~/.ssh/id_rsa

然后即可正常进行clone

四、git clone 出现

Permission denied (publickey).
fatal: The remote end hung up unexpectedly

详看大佬博客解决。电梯直达大佬方案

五、git bash 使用出现问题:

WARNING: terminal is not fully functional

- (press RETURN)

在关闭终端的时候,出现:

解决方案:

1、创建环境变量,注意大写哦,我就是在没有区分大小写的时候,折腾好久。

2、在终端选项中设置 终端类型 为 xterm

六、在 ssh-add 时候出现 Could not open a connection to your authentication agent.

经查,都在说明是以哦那个指令 ssh-agent bash 即可解决问题,但是本人并未有效。

解决方案:

在使用上面指令没有效果之后,直接重新生成key,由于本地还有其他的ssh key的原因,此时设置的时候没有使用默认的设置

$ ssh-keygen -t rsa -C "songshuai@git.com" # 邮箱使用自己的

$ ssh-add ~/.ssh/id_rsa_song
Identity added: /home/ma-sai-ke/.ssh/id_rsa_song (/home/ma-sai-ke/.ssh/id_rsa_song)

七、在windows中git bsah下进行git clone;然后报错

$ git clone git@github.com:sxxxxxxxg/nxxxxxxxxxc.git

Cloning into 'nxxxxxxxxxc'...

Warning: Permanently added 'github.com,13.229.188.59' (RSA) to the list of known hosts.

解决办法:

C:\Users\用户名\.ssh\下新建一个文件 config,注意没有后缀,并在文件中写入 LogLevel=quiet,保存退出。再次执行 git clone即可正常。

八、在windows中git bsah下进行git clone;然后报错

$ git clone  git@github.com:sxxxxxxxg/Soxxxxxxr.git
Cloning into 'Soxxxxxxr'...
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

不要慌,这个错误你只需要确保在远程仓库正确的情况下,检查网络然后重试基本就可以了。

九、在windows中git bsah下进行git clone;然后报错

$ git clone  git@github.com:sxxxxxxg/Soxxxxxxxer.git
Cloning into 'Soxxxxxxxer'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (2/2), done.
fatal: the remote end hung up unexpectedly | 0 bytes/s
fatal: early EOF
fatal: index-pack failed

对的,还是网络的问题。

持续更新......

 

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐