关于git:如何解决git-pushpull操作时出现的Operation-timed-out

5次阅读

共计 1093 个字符,预计需要花费 3 分钟才能阅读完成。

最近 git push 时常呈现Operation timed out,具体内容大略如下:

$ git push origin 72
ssh_dispatch_run_fatal: Connection to 192.30.255.112 port 22: Operation timed out
fatal: Could not read from remote repository.

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

意思是说:在连贯近程地址的 22 端口时超时了,而后要查看权限和近程仓库是否存在。

首先在网页端是能够拜访到该仓库的,所以问题并没有出在提醒的 权限或近程仓库

解决步骤

查看近程仓库地址

查看我的项目下的 .git/config 文件,留神 .git 文件夹是暗藏文件夹。

[remote "origin"]
        url = git@github.com:yunzhiclub/xxxx.git
        fetch = +refs/heads/*:refs/remotes/origin/*

得出近程仓库的地址是github.com

SSH

$ ssh github.com
panjie@github.com: Permission denied (publickey).

提醒权限不容许,确认网络可能拜访近程主机 22 端口。如果不能拜访,那么须要在网络上找起因了。第一先看是否能 ping 通,如果能 ping 通,则看防火墙策略是否禁用了 ssh 连贯或 22 端口。

ping

网络没有问题,那问题就应该呈现在证书上了。

ping github.com
panjieIMacdeiMac:app panjie$ ping github.com
PING github.com (192.30.255.112): 56 data bytes
64 bytes from 192.30.255.112: icmp_seq=0 ttl=36 time=297.969 ms

失去 github.com 的 ip 地址为 192.30.255.112。

vi ~/.git/known_hosts

找到 github.com,xx.xx.xxx.xxx 的一条,发现 xx.xx.xxx.xxx192.30.255.112并不统一,删除。

问题解决。

总结

git 不下来可能是由以下起因造成的:

  1. 仓库不存在或没有权限。验证:进行网页端登录。
  2. 网络问题。验证:ping 一下看通不通。
  3. ssh 或端口问题。验证:ssh github.com,看提醒的是网络谬误还是权限不容许。
  4. 证书问题:验证:比照 ~/.ssh/known_hosts 中的 主机名 ip 地址 是否与 ping 的后果统一,不统一则删除。
正文完
 0