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

相关推荐
霜落花轻扬11 小时前
git相关命令
git
xlq2232214 小时前
2.git
git
OYangxf14 小时前
Git Ignore
大数据·git·elasticsearch
哆哆啦0015 小时前
obsidian远程同步方案:infiniCloud+remotely save方案
笔记·git·obsidian
西柚小萌新16 小时前
【计算机常识】--使用 Gitea 在本地/内网搭建 Git 私有服务器
服务器·git·gitea
zhangfeng113317 小时前
scp 命令的使用方法 什么软件支持 .git bash xshell .openssh
开发语言·git·bash
_君莫笑1 天前
大厂Git使用规范
git
无心水1 天前
【Hermes:安全、权限与生产环境】39、智能体也会犯错?Hermes 纠错、回滚与遗忘机制全指南 —— 让 AI 的错误像 Git 一样可逆可控
人工智能·git·安全·mcp协议·openclaw·hermes·honcho
南境十里·墨染春水2 天前
linux学习进展 git详解
linux·git·学习
zhangfeng11332 天前
CodeBuddy ai对话框上面的git docs terminal Rulds 干嘛用的,以thinkphp fastadmin 为例,插件市场
人工智能·git·编程