最新消息:20210917 已从crifan.com换到crifan.org

【部分解决】Mac中给git添加加一次的当前的临时代理

Mac crifan 540浏览 0评论
折腾:
【未解决】Mac中用facebook-wda自动化测试操作iOS设备
期间,此处用git去clone结果报错:
 git clone https://github.com/appium/WebDriverAgent.git  Cloning into 'WebDriverAgent'...
remote: Enumerating objects: 25, done.
remote: Counting objects: 100% (25/25), done.
remote: Compressing objects: 100% (23/23), done.
error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
所以想要去加上代理去加速下载
之前已经知道如何加全局的代理了:
【整理Book】Git开发总结
是:
git config --global http.proxy socks5://127.0.0.1:1086
但是此处又不想要全局的加代理
只是想要加个 临时的,加一次,针对当前的git clone加代理
不知道具体如何操作
git one time proxy
去试试不加global,是不是只是针对当前git
 git config http.proxy socks5://127.0.0.1:1086

 git config http.proxy                        
socks5://127.0.0.1:1086
然后试试git clone
貌似用上代理了?
结果不是:因为关闭了代理,还继续能下载。
算了,给全局加上:
 git config --global http.https://github.com.proxy socks5://127.0.0.1:1086
 cat ~/.gitconfig
[user]
        email = xxx
        name = crifan.li
[http]
        postBuffer = 1048576000
        emptyAuth = true
[http "https://github.com"]
        proxy = socks5://127.0.0.1:1086
然后去下载,应该是有代理的
的确是的:
关闭了ss代理后,立刻断开了:
 git clone https://github.com/appium/WebDriverAgent.git                   
Cloning into 'WebDriverAgent'...
remote: Enumerating objects: 25, done.
remote: Counting objects: 100% (25/25), done.
remote: Compressing objects: 100% (23/23), done.
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
后来换了 荷兰的节点,速度还凑合,在300多KB
那等待下载完毕:
# git clone https://github.com/appium/WebDriverAgent.git
Cloning into 'WebDriverAgent'...
remote: Enumerating objects: 25, done.
remote: Counting objects: 100% (25/25), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 21492 (delta 4), reused 9 (delta 2), pack-reused 21467
Receiving objects: 100% (21492/21492), 17.03 MiB | 367.00 KiB/s, done.
Resolving deltas: 100% (9049/9049), done.
再去取消代理
 git config --global unset http.proxy
error: key does not contain a section: unset
好像不对。同时看到的确没取消掉:
 cat ~/.gitconfig
[user]
        email = xxx
        name = crifan.li
[http]
        postBuffer = 1048576000
        emptyAuth = true
[http "https://github.com"]
        proxy = socks5://127.0.0.1:1086
再去试试:
git config --global --unset http.https://github.com.proxy
是可以的
 git config --global --unset http.https://github.com.proxy
 cat ~/.gitconfig
[user]
        email = xxx
        name = crifan.li
[http]
        postBuffer = 1048576000
        emptyAuth = true
后来某次加了代理
git config --global http.https://github.com.proxy socks5://127.0.0.1:10860
后的速度变化:
且如果V2RayU中更换速度更快的节点后,速度提升更明显:
用完再去取消:
git config --global --unset http.https://github.com.proxy
效果:
➜  Downloads cat ~/.gitconfig
...
[http "https://gitee.com/"]
    proxy =

[http "https://github.com"]
    proxy = socks5://127.0.0.1:1080
➜  Downloads git config --global --unset http.https://github.com.proxy
➜  Downloads cat ~/.gitconfig
...
[http "https://gitee.com/"]
    proxy =
【总结】
此处,git中没有可以设置,当前这次的,临时的,只有一次的代理。
只能间接的实现,此处单独针对于GitHub的:
  • 全局的设置代理
    • git config –global http.https://github.com.proxy socks5://127.0.0.1:1086
  • git clone下载:可以用上代理加速了
    • git clone https://github.com/appium/WebDriverAgent.git
  • 再去取消代理
    • git config –global –unset http.https://github.com.proxy
注:
1.上述的
socks5://127.0.0.1:1086
指的是:
  • socks5代理
    • 如果额外有http的代理,也可以,比如:
      • http://127.0.0.1:1086
  • 端口是:1086
    • 如果你的端口不是1086,千万要记得更换成自己的代理的端口!
      • 我此处后来某次本地代理端口就是1080
2.随时可以用
cat ~/.gitconfig
查看当前全局的设置,是否正确:
(1)的确设置了代理
[http "https://github.com"]
        proxy = socks5://127.0.0.1:1086
(2)的确取消了代理
看不到http部分的proxy字段
心得:
(1)如果git下载报错  error: RPC failed; curl 35 LibreSSL SSL_connect,可以多试几次,或许就好了
之前遇到过几次,git下载报错了:
➜  temp git clone https://github.com/fcamblor/oh-my-zsh-agnoster-fcamblor.git
Cloning into 'oh-my-zsh-agnoster-fcamblor'...
error: RPC failed; curl 35 LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
fatal: the remote end hung up unexpectedly
➜  temp git clone https://github.com/fcamblor/oh-my-zsh-agnoster-fcamblor.git

remote: Enumerating objects: 136, done.
remote: Total 136 (delta 0), reused 0 (delta 0), pack-reused 136
Receiving objects: 100% (136/136), 1.14 MiB | 741.00 KiB/s, done.
Resolving deltas: 100% (59/59), done.
此时并没有改动代理服务器节点,而是多试了一次(或多次),就又好了。

转载请注明:在路上 » 【部分解决】Mac中给git添加加一次的当前的临时代理

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
92 queries in 0.209 seconds, using 23.32MB memory