debian下设置git的http代理

首先安装corkscrew。

 

1
sudo apt-get install corkscrew

 

接着,写一个proxy wrapper。

 

1
2
3
4
5
6
#!/bin/bash
#git proxy wrapper
# Put your own values
PROXY_IP=10.0.8.0
PROXY_PORT=8080
corkscrew ${PROXY_IP} ${PROXY_PORT}  $*  /path/to/proxy-auth

 

corkscrew的参数分别为:代理服务器的地址,代理服务器端口,所要代理的网址,认证文件。

认证文件中包含用户名和密码,形式为“user:password”。

将这个wrapper保存到文件proxy-wrapper中。

修改git的默认配置文件,通常是/home/xxx/.gitconfig。

在[core]段添加需要代理的服务器。如:

 

1
2
3
[core]
    gitproxy="/home/XXX/bin/proxy-wrapper" for XXXXX1.org
    gitproxy="/home/XXX/bin/proxy-wrapper" for XXXXX2.com

 

这样就可以了。。。

git还支持ssh和http协议。通过对本机的http代理或者ssh代理进行设置,可以通过这两个协议访问。

我的git配置文件:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
[user]
    name = xxx
    email = xxx@gmail.com
[core]
    editor = vim
    gitproxy="/home/xxx/bin/proxy-wrapper" for gnome.org
    gitproxy="/home/xxx/bin/proxy-wrapper" for github.com
[color]
    status = auto
    branch = auto
    diff = auto
    ui = true
    pager = true
[color "branch"]
    current = yellow reverse
    local = yellow
    remote = green
[color "diff"]
    meta = yellow bold
    frag = magenta bold
    old = red bold
    new = green bold
[color "status"]
    added = yellow
    changed = green
    untracked = cyan
[alias]
    co = checkout
    br = branch
    cm = commit
    st = status
posted @   kernel@hcy  阅读(4175)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
点击右上角即可分享
微信分享提示