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

相关推荐
解道Jdon2 小时前
[Budi插件:VsCode状态栏显示Copilot使用情况
ide·windows·git·svn·eclipse·github·visual studio
kisshyshy2 小时前
掌握 Git 基础
git
全糖可乐气泡水3 小时前
Codex适配国产信创环境安装部署与技术适配全解析
开发语言·git·python·算法·百度
一只大袋鼠5 小时前
Git 四种仓库连接方式操作指南
git
活宝小娜8 小时前
git windows安装教程
git
青春喂了后端10 小时前
Go Sidecar Repository 并发锁改造:让并发请求安全地进入 Git 仓库层
git·安全·golang
小雨青年10 小时前
GitHub Actions 工作流性能优化实战,先看瓶颈,再改缓存和并发
git
0x000712 小时前
Git Bash 中无法启动 Claude Code ?
开发语言·git·bash
xuhaoyu_cpp_java12 小时前
Git学习(六)
git·学习
happyness441 天前
Git:AI编程时代的“安全带“与“时光机“
git·ai编程