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

相关推荐
wh_xia_jun15 小时前
Git 分支合并操作备忘录
git
满天星830357717 小时前
【Git】原理及使用(三)(分支管理)
linux·git
像风一样的男人@20 小时前
warning: could not find UI helper ‘git-credential-manager-ui‘
git·ui
代钦塔拉1 天前
Git & GitHub 从入门到精通:全流程实战教程
git·github
晚风吹红霞1 天前
Linux下的趣味编程 —— 进度条、Git版本控制与GDB调试实战
linux·运维·git
xlq223221 天前
7.git
git
Ws_1 天前
Git + Gerrit 第六课:commit --amend、Patch Set 与 Change-Id
git
AIMath~2 天前
向github中上传文件过大超过50M怎么办
网络·git·github
AIMath~2 天前
如何将一个新的文件夹使用git 工具提交到github新仓库中
git·github
满天星83035772 天前
【Git】原理及使用(二) (版本回退)
linux·git