From 733b699341774bc9bd935f6c1b622779c0bb7e89 Mon Sep 17 00:00:00 2001 From: jaywcjlove Date: Tue, 1 Nov 2022 08:14:46 +0000 Subject: [PATCH] doc: update `git.md`. (#15) ff9d38de1785f5148f8335aa1ee69271a82a4046 --- CONTRIBUTORS.svg | 2 ++ docs/git.html | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTORS.svg b/CONTRIBUTORS.svg index 3c3c5c19..9b96758f 100644 --- a/CONTRIBUTORS.svg +++ b/CONTRIBUTORS.svg @@ -14,5 +14,7 @@ + + \ No newline at end of file diff --git a/docs/git.html b/docs/git.html index 42bb3903..3e8b32fd 100644 --- a/docs/git.html +++ b/docs/git.html @@ -41,7 +41,7 @@

本备忘单总结了常用的 Git 命令行指令,以供快速参考。

入门

+

入门

创建存储库

创建一个新的本地存储库

$ git init [项目名称]
@@ -528,10 +528,35 @@
 

不添加参数,默认是 -mixed

配置 http 和 socks 代理

-
# 适用于 privoxy 将 socks 协议转为 http 协议的 http 端口
-git config --global https.proxy 'http://127.0.0.1:8001'
-git config --global http.proxy 'http://127.0.0.1:8001'
-git config --global socks.proxy "127.0.0.1:1080"
+
# 查看代理
+$ git config --global http.proxy
+$ git config --global https.proxy
+$ git config --global socks.proxy
+
+# 设置代理
+# 适用于 privoxy 将 socks 协议转为 http 协议的 http 端口
+$ git config --global http.proxy http://127.0.0.1:1080
+$ git config --global https.proxy http://127.0.0.1:1080
+$ git config --global socks.proxy 127.0.0.1:1080
+
+# 取消代理
+$ git config --global --unset http.proxy
+$ git config --global --unset https.proxy
+$ git config --global --unset socks.proxy
+
+# 只对 github.com 设置代理
+$ git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
+$ git config --global https.https://github.com.proxy socks5://127.0.0.1:1080
+
+# 取消 github.com 代理
+$ git config --global --unset http.https://github.com.proxy
+$ git config --global --unset https.https://github.com.proxy
+
+

配置 SSH 协议代理

+
# 对于使用 git@ 协议的,可以配置 socks5 代理
+# macOS 系统编辑 ~/.ssh/config 文件,添加这几行,设置 github 代理
+Host github.com
+  ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p
 

另见