Git 设置代理

Git 传输分两种协议,SSH和 http(s),设置代理也需要分两种。

http(s) 代理

Command Line

使用 命令行 模式,可以在Powershell中使用以下命令设置代理:

bash 复制代码
$env:http_proxy="http://127.0.0.1:7890"
$env:https_proxy="http://127.0.0.1:7890"

TortoiseGit

SourceTree

SSH 代理

在目录 【C:\Users\用户名\.ssh】下添加一个 config 文件,并在文件中添加以下配置

bash 复制代码
Host github.com
  User git
  Port 22
  Hostname github.com
  IdentityFile "C:/Users/[用户名]/.ssh/id_rsa"
  ProxyCommand connect -S 127.0.0.1:7890 -a none %h %p
  TCPKeepAlive yes

PS

虽然使用SSH,但是因为Git拉取 子模块,LFS时使用的是http传输,所以在使用ssh克隆时,如果仓库中有子模块或者LFS,也需要同时设置http代理。

相关推荐
Dontla7 小时前
git bash打开Claude code报错:Claude Code on Windows requires git-bash.(别把git装其他位置,严格按照默认安装)找不到claude code
windows·git·bash
一个梦醒了7 小时前
安装git bash选项推荐
开发语言·git·bash
呆萌的代Ma10 小时前
Git不强行推送,撤销最近几次的提交
git
透明的玻璃杯13 小时前
git应用
git
炸炸鱼.14 小时前
Git+Jenkins实战(一):从零搭建自动化发布与回滚系统(附完整代码)
git·jenkins
言66617 小时前
要忽略前端依赖包node_modules的文件在目录下 git暂存区消失
git
胡小禾18 小时前
Git Worktree
git
程序员小羊!18 小时前
18 GIt
git
怣疯knight18 小时前
Git 本地分支关联远程分支 常用命令汇总
git
ANNENBERG18 小时前
git分支开发管理
git