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代理。

相关推荐
触底反弹6 小时前
🔥 Git 从零到精通:彻底搞懂核心概念与工作原理
git·面试·开源
tokenKe10 小时前
Epic Games 发布下一代版本控制系统 Lore:被 HN 干到 1000+ 分的“游戏版 Git“
git·游戏
Eira-Z12 小时前
git(持续学习中...)
git·学习
leoZ23115 小时前
Git 集成实战完全指南(五):Git Blame 与历史追踪
大数据·git·elasticsearch
leoZ23116 小时前
Git 集成实战完全指南(六):Git 标签与版本管理
大数据·git·elasticsearch
leoZ2312 天前
Git 集成实战完全指南(三):自动化 Commit 与 PR
大数据·git·elasticsearch
国服第二切图仔2 天前
002-Claude Code 项目解读:入口与启动流程
linux·git·ubuntu
天空'之城2 天前
VS Code Git 工作树:告别频繁切分支,实现多分支并行开发实战方案
git·vscode·版本控制·嵌入式开发·开发效率·worktree·多分支管理
程序员爱德华2 天前
VSCode git/gerrit解冲突
git·vscode·gerrit
leoZ2312 天前
Git 集成实战完全指南(二):智能分支管理
大数据·git·elasticsearch