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

相关推荐
Ws_8 小时前
Git + Gerrit 第二课:diff、暂存区与撤销修改
git
snowjlz9 小时前
鸿蒙版SVN来了!!!
git·svn·版本控制
2401_8769641310 小时前
27考研余炳森概率论|喻老李良2027资料网课
windows·git·考研·svn·eclipse·github·概率论
爱搬砖的狮子11 小时前
【Git】git repo下载使用
git
cheems952714 小时前
Git基本操作
git
Irissgwe15 小时前
三、Git 文件状态管理:add、commit、status 和 diff
git
Ws_19 小时前
Git + Gerrit 第三课:分支、切换与合并
git·elasticsearch
xlq2232220 小时前
6.git
git
Drache_long20 小时前
Git命令概述
git
console.log('npc')20 小时前
修改git中commit内容
git