Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub 项目用代理推送至服务器 #18

Closed
Dream4ever opened this issue May 25, 2018 · 0 comments
Closed

GitHub 项目用代理推送至服务器 #18

Dream4ever opened this issue May 25, 2018 · 0 comments
Labels
Deployment Deploy content to server Server The invisible hero

Comments

@Dream4ever
Copy link
Owner

需求描述

在本机编写的项目,时不时地就因为众所周知的原因无法推送到 GitHub 上了。既然阳关大道走不通,那就只好走独木桥了。

方案调研

调研过程

本机的项目往 GitHub 推送失败时,会报下面的错误:

ssh: connect to host github.com port 22: Connection timed out

用上面的报错信息 Google,看到 Stack Overflow 上有解决方法:git - ssh: connect to host github.com port 22: Connection timed out | Stack Overflow

上面的修改只是让本机项目走 http 协议,还要让项目走本地代理才行,设置方式参考:laispace/git 设置和取消代理

入选方案

应用过程

在终端先用指令 ssh -T git@github.com 测试是否能通过 ssh 连接到 GitHub 上,如果提示连接超时,说明 ssh 的确连不到 GitHub 上。

ssh 不行,那就换 http 方式。在项目所在目录中,执行 git config --local -e,会显示当前项目的 git 设置,把 ssh 方式的 URL:url = git@github.com:username/repo.git 改成 http 方式的 URL:url = https://github.com/username/repo.git

然后!不要忘了然后,还要让 git 走本地代理。当然了,http.proxyhttps.proxy 后面究竟是用 socks5 还是 http,都要看代理软件的设置,根据自己的实际情况来就行。

$ git config --global https.proxy 'socks5://127.0.0.1:1080'
$ git config --global http.proxy 'socks5://127.0.0.1:1080'

要点总结

Google + Stack Overflow 解决程序员所有问题 😄

@Dream4ever Dream4ever added Deployment Deploy content to server Software About installation ande usage Server The invisible hero and removed Software About installation ande usage labels May 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deployment Deploy content to server Server The invisible hero
Projects
None yet
Development

No branches or pull requests

1 participant