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

相关推荐
m0_579146654 小时前
已被 Git 追踪的本地修改文件如何实现临时忽略
git
糖少主6 小时前
WSL中使用Beyond Compare 3/4/5作为difftool
git·wsl·beyond compare·difftool
console.log('npc')8 小时前
Git版本管控:git reset \+ git push \-f 原理、实操与避坑指南
git
恋喵大鲤鱼13 小时前
git reflog
git·git reflog
MatrixOrigin14 小时前
MatrixOne Git4Data 技术详解(二):从零跑通所有 Git 原语
git
anew___15 小时前
常用的 Git 工作流
git
shimly12345615 小时前
git diff 生成一部分文件的补丁
git
m0_5791466516 小时前
Git 重置模式详解:四种重置方式的原理与应用场景
git
恋喵大鲤鱼16 小时前
git grep
git·git grep
霸王龙的小胳膊16 小时前
Git基础知识
git