[Git] Git 使用常见问题

1、错误:Write failed: Broken pipe

有时在执行 pull 或者 push 操作时,会出现如下错误:
packet_write_wait: Connection to 192.30.255.113 port 22: Broken pipe
如果出现这一问题,请编辑 /etc/ssh/ssh_config 文件:

在文件中添加如下配置:

参考:
http://www.voidcn.com/article/p-bvmncksl-oe.html

2、错误:The remote end hung up unexpectedly

在执行 git clone 时如果出现如下错误:
Cloning into 'ORB_SLAM2'...
The authenticity of host 'github.com (192.30.255.112)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.255.112' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

很可能是因为你没有加入本地的 publickey 到 Github 上面(使用客户端的朋友可能客户端会自动添加,不过命令行的不一定)。
操作步骤如下:
1)执行如下命令:

2)生成本地的publickey文件,然后拷贝文件内容到:
https://github.com/settings/keys
点击 [New SSH Key] 进行添加。

3)如果你不是使用默认的 ~/.ssh/id_rsa.pub 保存的话,需要如下操作将秘钥加入 ssh 端。例如你保存的文件是 skylook.pub 则运行如下命令:

注意这里是 skylook 而不是 skylook.pub。

如果此步骤运行提示如下错误:
WARNING: UNPROTECTED PRIVATE KEY FILE!
可以执行如下命令设置权限:

4)测试可用性:
执行如下命令:

如果看到:
Hi skylook! You've successfully authenticated, but GitHub does not provide shell access.
则表示添加成功了。

3、错误:pack-objects died of signal 13

如果此步骤运行提示如下错误:
Counting objects: 78431, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (60772/60772), done.
remote: fatal: pack exceeds maximum allowed size
fatal: The remote end hung up unexpectedly
error: pack-objects died of signal 13
error: failed to push some refs to 'git@github.com:skylook/QAR.git'

可以尝试如下命令加大 http.postBuffer 的值:

4、错误:无法 push 到 Github,报Connection reset by 20.205.243.166 port 22

一般情况下,这一错误与使用了代理有关,一个简单的解决方法是将 Github 的连接端口从 22 改为 443 即可。
编辑 ~/.ssh/config 文件(没有就新增),添加如下内容:

测试可用性:
执行如下命令:

如果看到:
Hi skylook! You've successfully authenticated, but GitHub does not provide shell access.
则表示添加成功了。

Add a Comment

您的电子邮箱地址不会被公开。 必填项已用 * 标注