• 请不要在回答技术问题时复制粘贴 AI 生成的内容
ninvfeng
20D
V2EX  ›  程序员

一个 github 拉取推送加速的思路

  •  
  •   ninvfeng · Aug 28, 2025 · 6856 views
    This topic created in 433 days ago, the information mentioned may be changed or developed.

    这两天好像 github 拉取推送都超时了~

    在 ~/.ssh/config 中添加

    Host github.com
      User git
      HostName github.com
      ProxyJump proxyserver
      
    Host proxyserver
      User root
      HostName your_server_ip
      IdentityFile xxx
    

    其中 proxyserver 是你 hk 或海外可以直连 github 的服务器

    Supplement 1  ·  Aug 28, 2025

    感谢5楼提供的方案, 直接使用已有代理更加简单方便

    Host github.com
      User git
      HostName github.com
      ProxyCommand ncat --proxy-type socks5 --proxy 127.0.0.1:9999 %h %p
    

    提示没有ncat的话需要先安装

    34 replies  •  2025-09-01 09:56:46 +08:00
    FabricPath
    FabricPath
    Aug 28, 2025
    1
    有点麻烦,还是:

    1. 家里软路由部署透明代理
    2. 出门在外打洞回家,从家里代理出去

    一劳永逸
    coolcoffee
    coolcoffee
    Aug 28, 2025
    2
    最好不要用 ssh 大流量跑,速度慢不说还很容易被墙给干掉的。 正确的做法还是应该走本地的 socks5 服务器🐶
    irrigate2554
    irrigate2554
    Aug 28, 2025
    3
    透明代理 + https 协议拉取
    pingdog
    pingdog
    Aug 28, 2025 via Android
    4
    既然你都有国际服务器了,本地开 proxy 算是基础,为什么不直接用 Proxycommand……
    superrichman
    superrichman
    Aug 28, 2025❤️1
    5
    直接上 ProxyCommand ,随便弄个代理都能用

    ProxyCommand ncat --proxy-type socks5 --proxy 127.0.0.1:9999 %h %p
    mrgeneral
    mrgeneral
    Aug 28, 2025
    6
    直接 TUN 接管
    bigtear
    bigtear
    Aug 28, 2025
    7
    偶尔简单用一下还不错
    ssh 大流量容易被盯上或者阻断
    waklealone
    waklealone
    Aug 28, 2025
    8
    surge 增强模式就行
    jiangzm
    jiangzm
    Aug 28, 2025❤️1
    9
    ProxyCommand nc -v -x 127.0.0.1:7890 %h %p
    Tohrusky
    Tohrusky
    Aug 28, 2025
    10
    tun mode 解君愁
    skiy
    skiy
    Aug 28, 2025 via iPhone
    12
    用这个: https://github.com/shunf4/proxychains-windows

    linux 平台也有。proxychains git 这样胜,在命令行前面加 proxychains 就行了(首先要加入 PATH )
    skiy
    skiy
    Aug 28, 2025 via iPhone
    13
    up 的环境看起来不像 win ,那就用正面这个。自己 build 一下就行了,c 写的。
    https://github.com/rofl0r/proxychains-ng
    kennylam777
    kennylam777
    Aug 28, 2025
    14
    年輕人終究是年輕人, 太衝動了, 不知道牆有多高, 觸發阻斷的流量有多大.......
    wangtian2020
    wangtian2020
    Aug 28, 2025
    15
    感觉不如 tun 模式启动
    jocover
    jocover
    Aug 28, 2025
    16
    直接用 proxychains 就行了,你这个太麻烦了
    starrys
    starrys
    Aug 28, 2025
    17
    温馨提示:国内使用代理访问 github 最快的是日本节点。
    kristofer
    kristofer
    Aug 28, 2025
    18
    直接 tun ,折腾那么多太费事了,还不一定稳。
    UnluckyNinja
    UnluckyNinja
    Aug 28, 2025❤️1
    19
    windows 应该不需要额外安装别的,一直用的下面这个,忘记从哪个 stackoverflow 捞来的了
    Host github.com
    User git
    ProxyCommand connect -S localhost:7890 %h %p
    Hostname ssh.github.com
    Port 443
    BitGeek
    BitGeek
    Aug 28, 2025
    20
    我在 linux 里的方案是直接在/etc/profile 里添加 all_proxy=...
    Oxygen2025
    Oxygen2025
    Aug 28, 2025
    21
    直接开 tun 模式就行了
    wweir
    wweir
    Aug 28, 2025
    22
    现在,是更推荐使用 HTTPS 方式拉取,而不是 SSH 的,这样的话,一行命令解决所有问题:

    git config --global http.https://github.com.proxy socks5h://127.0.0.1:1080
    tayuo
    tayuo
    Aug 28, 2025
    23
    一直是手动添加 ssh.github.com

    git remote add origin [email protected]:user/repo.git

    目前来说很顺畅
    wenrouxiaozhu
    wenrouxiaozhu
    Aug 28, 2025
    24
    ╰─ alias proxy  100% 
    proxy='export https_proxy=http://127.0.0.1:7890;export http_proxy=http://127.0.0.1:7890;export all_proxy=socks5://127.0.0.1:7890'

    我是这样
    gsw945
    gsw945
    Aug 28, 2025 via iPhone
    25
    我一般是用 #13 楼 说的 proxychains-ng 配置 socks5 ,本机 clash 允许局域网连接,服务器上除了不依赖 gLibC 的的程序(一般纯 go 的),基本都能用。
    liyafe1997
    liyafe1997
    Aug 28, 2025
    26
    我一般直接 proxychains git xxx
    SeanChang
    SeanChang
    PRO
    Aug 28, 2025❤️1
    27
    改 hosts 也是个方便的方式~

    https://githubhosts.xuanyuan.me
    gongym
    gongym
    Aug 29, 2025
    28
    为什么不直接配置.gitconfig 。又改 ssh 又改 host 。不麻烦嘛
    realJamespond
    realJamespond
    Aug 29, 2025
    29
    用了很多年了,用 ssh config 基本不需要啥 xshell securtcrt 之类的了
    ProxyCommand nc -X 5 -x localhost:1080 %h %p
    MIUIOS
    MIUIOS
    Aug 29, 2025
    30
    tun 不就完事了
    taowen
    taowen
    Aug 29, 2025
    31
    w568w
    w568w
    Aug 29, 2025
    32
    ncat 会有一些上传下载的性能问题,跑不满带宽。可以试试我之前搞的代理小工具: https://github.com/w568w/sucks5
    flyqie
    flyqie
    Aug 31, 2025 via Android
    33
    现在为什么要用 ssh 呢,不太理解。

    感觉 http/https 拉取和推送一般来说也能满足需求吧?
    jmliubiao
    jmliubiao
    Sep 1, 2025
    34
    直接导入到码云上,从码云上拉取
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2403 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 114ms · UTC 15:43 · PVG 23:43 · LAX 07:43 · JFK 10:43
    ♥ Do have faith in what you're doing.