摘要:

因为网络环境限制 ,github在国内访问比较慢,有时项目比较大时,经常拉取不下来。

1、Git 设置代理

用Git内置代理,直接走系统中运行的代理工具中转,比如你的代理工具本地端口是 1080,那么可以如下方式走代理:

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

查看当前代理

1
2
git config --global http.proxy
git config --global https.proxy

取消代理

1
2
3
git config --global --unset http.proxy

git config --global --unset https.proxy

2、拉取最近的一次提交

可以在git clone中加入参数 –depth=1,只拉取最近的一个 revision

1
git clone --depth=1 https://XXX

如果后面想看历史的版本,使用 git fetch 即可:

1
git fetch --unshallow