我在代理下,我在相当长的一段时间内成功地推进。 现在我突然不能进入git了。 我已经设置了RSA密钥和代理,并仔细检查了它们,没有效果,git抛出了页面标题中显示的错误。


当前回答

快速解决方法:尝试切换到不同的网络

我在热点(3/4G连接)时遇到了这个问题。切换到不同的连接(WiFi)解决了这个问题,但这只是一个变通办法——我没有机会深入了解问题的根源,所以其他答案可能更有趣,可以确定潜在的问题

其他回答

问题

产生问题的步骤:git克隆git@github.com:sramachand71/test.git 这是新笔记本电脑里的第一次

错误

ssh: connect to host github.com port 22: Connection timed out
 fatal: Could not read from remote repository.

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

解决方案

第一次在系统中克隆时,我们需要给clone命令加双引号。

$ git clone "git@github.com:sramachand71/test.git"

我在系统中遇到这个问题,即使一切都是正确的,但最后注意到双引号是url“repository_url”必须的。第一次或新用户在系统中。

原因可能是防火墙修改,因为您处于网络中。(在这种情况下,他们可能会故意封锁一些端口) 再次确认这是否是原因…做

ssh -T git@github.com

这应该会超时。 如果是这种情况,使用http协议而不是ssh 只需将配置文件中的url更改为http。 方法如下:-

git config --local -e

变更分录

 url = git@github.com:username/repo.git

to

url = https://github.com/username/repo.git

在.ssh文件夹中 创建config文件

Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443

Host gitlab.com
Hostname altssh.gitlab.com
User git
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa

将repo url从ssh更改为https对我来说没有多大意义。因为我更喜欢ssh而不是https,因为我不想放弃一些额外的好处。以上答案都很好,也很准确。如果你在GitLab遇到这个问题,请去他们的官方文档页面,并像那样修改你的配置文件。

Host gitlab.com
  Hostname altssh.gitlab.com
  User git
  Port 443
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/gitlab

刷新我的网络连接对我很有效。

此外,如果你使用移动热点-重新启动移动设备是解决方案在我的情况下。