avatar

Git代理设置

1. 前期准备

  • 代理服务器
  • 代理软件

2. 代理服务器

  • 打开代理软件,连接上代理服务器

  • 确定代理软件的占用端口,一般默认1080端口 今天突然发现蛇皮了,将鼠标移动到小图标会显示出端口号
    upload successful

  • 如果你用的其他代理软件,不知道端口号是多少,可用下面方法查看
    1.打开设备管理器,找到代理软件的详细信息确认PID
    pid
    2.CMD打开命令行,查看端口占用信息,使用netstat -ano命令即可查看全部端口占用信息

    3.Ctrl+F查找之前找到的PID,确认占用端口
    port

3. 设置git代理

  • 打开Git Bash
  • 设置代理
1
2
3
4
5
6
7
8
9
#全局设置
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080

#只对github.com代理
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

# 本次设置
git clone https://github.com/example/example.git --config "http.proxy=127.0.0.1:1080"
  • 取消设置代理
1
2
3
4
5
6
7
8
9
# 取消全局代理
git config --global --unset http.proxy
git config --global --unset https.proxy

# 或者
npm config delete proxy

# 取消github.com代理
git config --global --unset http.https://github.com.proxy

4.测试结果

代理测试
成功!!

文章作者: HU
文章链接: https://www.blog-z.gq/2020/01/29/gitproxy/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 BIA
打赏
  • 微信
    微信
  • 支付寶
    支付寶

评论