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

相关推荐
六bring个六2 小时前
git使用笔记
笔记·git
最后冰吻free5 小时前
git 不新增commit修改中间commit对应的文件
git
芳草萋萋鹦鹉洲哦5 小时前
【git】重新生成并添加 SSH Key(Mac)
git·macos·ssh
午安~婉6 小时前
git中http与ssh连接
git·http·ssh
@Demi6 小时前
前端开发 Git 分支与 Tag 管理规范
大数据·git·elasticsearch
炸膛坦客1 天前
Git 和 GitHub:(七)将本地新建仓库与 GitHub 远程仓库关联起来(SSH)
git·ssh·github
炸膛坦客1 天前
Git 和 GitHub:(六)在本地新建仓库并进行一次提交
git·github
2301_809815252 天前
Git和Gitee基本使用教程
git·gitee
雨翼轻尘2 天前
01_Git概述及基本操作
git·概述·基本操作
程序员果子2 天前
CrewAI :当 Agent 学会团队协作
人工智能·git·python·多智能体·agent框架