git协议配置代理(git://)

文档说明: 只记录关键的地方; 发布时间: 2023-08-31
环境:docker
目的: 方便下载使用 git:// 协议的仓库源代码
状态: 已完成
备注:

运行准备依赖

debian 环境

apt install -y netcat 

alpine 环境

apk add netcat-openbsd

准备 git-proxy 脚本

脚本 git-proxy 是自定义脚本
脚本放任何位置都可以
脚本需要可执行权限
创建文件 /tmp/git-proxy


cat  > /tmp/git-proxy <<___EOF___
#!/bin/bash

# 使用http-proxy
nc -X connect  -x 127.0.0.1:8016 "\\$1" "\\$2"

# 使用socks5 配置
# nc -X 5 -x 127.0.0.1:2000 "\\$1" "\\$2"

___EOF___


# 给脚本添加可执行权限
chmod a+x /tmp/git-proxy

使用 git-proxy 方式一:


export GIT_PROXY_COMMAND=/tmp/git-proxy

git clone git://git.postgresql.org/git/postgresql.git

git clone git://git.kernel.org/pub/scm/linux/kernel/git/zx2c4/wireguard-linux.git

使用 git-proxy 方式二:

这个配置影响 git:// 全局,使用完毕,应该恢复为默认

git config --global core.gitproxy "/tmp/git-proxy"

# 查看配置情况 
git config --get --global core.gitproxy

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

# 使用完毕,恢复为默认
git config --global core.gitproxy ""

查考文档

  1. linux kernel
  2. Kernel.org git repositories
  3. linux 源码在线预览
  4. postgresql
  5. How to Proxy Git Connections
  6. Using_git_with_a_proxy
posted @ 2023-08-31 12:55  jingjingxyk  阅读(171)  评论(0编辑  收藏  举报