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


当前回答

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

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

其他回答

主要原因是公司最近安装的代理发生了变化,阻止了公司域以外的其他ssh连接。

我可以通过以下步骤成功连接:

仔细检查,这个问题是我所假设的 ssh -T git@github.com

它应该在一个超时中结束。

编辑本地远程URL

SSH配置——local -e

url = git@github。com: asheeshjanghu / Journal git。

to

url = https://github.com/asheeshjanghu/Journal.git

重要的一点是,在url中,你必须在2个地方改变。

从git@到https://,从github:username到github/username

最后通过git获取来验证

问题

产生问题的步骤: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”必须的。第一次或新用户在系统中。

执行:

nc -v -z <git-repository> <port>

你的输出应该是这样的:

"Connection to <git-repository> <port> port [tcp/*] succeeded!"

如果你得到:

connect to <git-repository> <port> (tcp) failed: Connection timed out

您需要编辑~/。ssh / config文件。添加如下内容:

Host example.com
Port 1234

重启电脑帮我解决了这个问题。 Git版本:2.27.0.windows.1 操作系统版本:Windows 10

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

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