如何配置 GitHub Desktop/Windows 以使用代理?

How Can I Configure GitHub Desktop/Windows to Work with a Proxy?

刚开始在 Windows 中使用 git。我下载了 GitHub 桌面应用程序并可以连接我的帐户,但是由于未解析的主机,pushes/pulls 操作失败。在工作场所询问后,我得到以下建议,将此命令键入 git shell.

git config --global http.proxy http://username:password@proxy.workplace.com:8080

是否这样做:

  1. 以明文形式存储我的密码?
  2. 以纯文本形式发送我的密码?

桌面版 GitHub 不会生成和使用 SSH 密钥(我在第一次连接帐户时收到电子邮件通知)吗?如何配置 GitHub 桌面以使用此代理?

所以实际上解决方案是将此命令键入 git shell。

git config --global http.proxy http://<proxy-ip>:<proxy-port>

它可能适用于此:

  • git 配置 --global http.proxy proxy_address:proxy_port
  • git 配置 --global https.proxy proxy_address:proxy_port

如果用户名和密码不是那么重要,那么使用:

  • git 配置 --global http.proxy username:password@proxy_address:proxy_port
  • git 配置 --global https.proxy username:password@proxy_address:proxy_port

直接向 Github 桌面添加代理而不使用 git shell:

  1. 在 Github Desktop 中将 up/Sign 设置到您的帐户(这不会有问题,proxy only 不允许您添加、创建或克隆回购)

  2. 暂时关闭Github桌面(设置代理)。

  3. 转到C:\Users\@yourusername

  4. 在那里你会找到一个名为 .gitconfig

  5. 的文件
  6. 用任意文本编辑器打开(我用的是sublime text 3)添加

[http] proxy = http://username:password@your.proxy.address:8080

并保存。

  1. 现在您可以在 Github 桌面中添加、创建和克隆存储库。

注意(对于 TFS 用户):当您使用上述代理配置时,TFS 将 return 502 bad gateway 错误。使用hash#注释掉.gitconfig中的代理配置,在Git和TFS之间切换。

尝试升级到 GitHub Desktop 2.4(2020 年 3 月)

Working behind a proxy

With GitHub Desktop 2.4, we automatically handle setup without needing you to configure anything manually—worry no more!