Files
nexus/wiki/concepts/Git代理配置.md

49 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Git HTTP/SOCKS5 代理配置"
type: concept
tags: [git, proxy, socks5, http, github]
---
## Definition
Git 代理配置是通过 `git config --global http.proxy``git config --global https.proxy` 全局设置,让 Git 的 HTTP/HTTPS/SSH 操作通过本地代理服务器进行。
## Commands
### HTTP 代理
```bash
git config --global http.proxy http://127.0.0.1:10809
git config --global https.proxy http://127.0.0.1:10809
```
### SOCKS5 代理(速度通常更快)
```bash
git config --global http.proxy socks5://127.0.0.1:10808
git config --global https.proxy socks5://127.0.0.1:10808
```
### 取消代理
```bash
git config --global --unset http.proxy
git config --global --unset https.proxy
```
### 查看当前配置
```bash
git config --global --get http.proxy
```
## Core Insight
设置代理后Git 的所有网络流量通过本地代理转发。GFW 只能看到通向本地代理的连接,无法识别目标域名,从根本上规避 TCP RST 攻击。
## Scope
- 全局(`--global`):影响当前用户所有 Git 仓库
- 本地(无 `--global`):仅影响当前仓库
- 仅影响 Git 命令,不影响终端其他程序
## Relationship to Other Concepts
- [[TCP RST 攻击]] ← solves代理让 GFW 无法检测 GitHub 域名
- [[SOCKS5 代理]] ← transport_layerSOCKS5 比 HTTP 代理更底层,支持更多协议
- [[V2RayN]] ← providesV2RayN 同时提供 HTTP 和 SOCKS5 代理端口
## Source
- [[Git Push 连接重置问题修复]]