V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
mikicomo
V2EX  ›  git

如何为 Git 设置代理规则?

  •  1
     
  •   mikicomo · 2016-10-12 20:59:24 +08:00 · 2363 次点击
    这是一个创建于 2724 天前的主题,其中的信息可能已经有所发展或是发生改变。

    国内譬如 Coding 、 OSC 直连

    Github 使用 socks5 代理

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

    如果使用这种方式的话就是全局代理了,有点拖累国内的速度。

    6 条回复    2016-10-12 23:52:52 +08:00
    sutra
        1
    sutra  
       2016-10-12 21:34:44 +08:00
    [http "https://example.com/repo1.git"]
    proxy = socks5://127.0.0.1:1080
    [http "https://example.com/repo2.git"]
    proxy = http://user:pass@proxy2:8080
    sutra
        2
    sutra  
       2016-10-12 21:36:26 +08:00
    yoa1q7y
        3
    yoa1q7y  
       2016-10-12 22:16:02 +08:00
    http_proxy=socks5://127.0.0.1:1080 https_proxy=socks5://127.0.0.1:1080 git push
    mikicomo
        4
    mikicomo  
    OP
       2016-10-12 22:30:19 +08:00
    @sutra 嗯,待会儿仔细看下,你这样的配置方法是要单个设置的吧?没仔细看,不过应该有全局的吧?

    @yoa1q7y 这样不是也比较烦了么....每次都要把?(还是就第一次需要,以后都不用了?)
    sutra
        5
    sutra  
       2016-10-12 22:32:52 +08:00   ❤️ 1
    @mikicomo 不是单个设置呀。是修改 ~/.gitconfig 文件。

    我再补充一个例子:这是针对这整个域名下的,而不是某个具体的 repo
    [http "https://weak.example.com"]
    proxy = socks5://127.0.0.1:2080
    mikicomo
        6
    mikicomo  
    OP
       2016-10-12 23:52:52 +08:00
    @sutra 嗯嗯,刚才没看仔细哈
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4320 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 01:03 · PVG 09:03 · LAX 18:03 · JFK 21:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.