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

相关推荐
我命由我123453 小时前
Android Studio - 在 Android Studio 中直观查看 Git 代码的更改
android·java·开发语言·git·java-ee·android studio·android jetpack
无证驾驶梁嗖嗖3 小时前
git_lab_事故恢复全过程(ubuntu_22
linux·git·ubuntu
何中应3 小时前
CentOS7安装Git
运维·git·centos·开发工具
微尘hjx4 小时前
【GitHub 代码仓 02】git命令操作示例
git·elasticsearch·github
阿正的梦工坊8 小时前
Git提交中的perf和chore是什么?
git
Fly feng8 小时前
git rebase 变基操作教程
git
laoliu19968 小时前
开源 FRP GUI 客户端
git·开源·github
YanaDH10 小时前
前端开发新机环境部署(带链接)
git·vscode·npm·node.js
微尘hjx11 小时前
【GitHub 代码仓 03】Git + GitHub 实战速查手册
git·github
艺杯羹1 天前
Git版本控制深度复盘:从入门到精通的完整指南
git·wpf·版本控制·git学习·git复盘