YangPengFe1 / yunydemo

保存优秀可用的插件和尝试用Issues写博客的Weber.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

git clone一个github上的仓库,报错或者太慢解决办法。

YangPengFe1 opened this issue · comments

  • 1.首先第一步前提是已经打开了SS代理。

  • 2.如果要设置全局代理,可以依照这样设置。

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

但请注意,需要查看自己的端口是不是也是1080,可以打开你的SS查看代理设置

  • 3.完成上面一步后,此时输入git clone xxxxxxx就可以利用代理进行下载了.
    但同时,也请注意,这里指的是https协议,也就是
git clone https://www.github.com/xxxx/xxxx.git

这种对于SSH协议,也就是

git clone git@github.com:xxxxxx/xxxxxx.git

这种,依旧是无效的

  • 4.以上为总结,但我不推荐直接用全局代理
    因为如果挂了全局代理,这样如果需要克隆coding之类的国内仓库,会奇慢无比
    所以我建议使用这条命令,只对github进行代理,对国内的仓库不影响
git config --global http.https://github.com.proxy https://127.0.0.1:1080
git config --global https.https://github.com.proxy https://127.0.0.1:1080

同时,如果在输入这条命令之前,已经输入全局代理的话,可以输入进行取消

git config --global --unset http.proxy
git config --global --unset https.proxy
  • 5.git 设置 socks5 代理。 ss暴露的是socks5。socks5代理的方法.
git config --global http.proxy 'socks5://127.0.0.1:1080'  
git config --global https.proxy 'socks5://127.0.0.1:1080'

开始 clone,如果觉得仓库太大,可以在 git clone 中加入参数 --depth=1,只拉取最近的一个 revision。

git clone --depth=1 https://github.com/torvalds/linux.git

如果后面想看历史的版本,那么也很好办,使用 git fetch 即可

git fetch --unshallow