From 2e8224ba17d6e4d101f70cf39491516da05b78af Mon Sep 17 00:00:00 2001 From: jaywcjlove Date: Tue, 1 Nov 2022 08:36:32 +0000 Subject: [PATCH] doc: update `git.md`. 6d602f3e898757b72bf4c518c24cc675112bd809 --- docs/git.html | 53 ++++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/docs/git.html b/docs/git.html index 3e8b32fd..c4b8f311 100644 --- a/docs/git.html +++ b/docs/git.html @@ -41,7 +41,7 @@

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

入门

+

入门

创建存储库

创建一个新的本地存储库

$ git init [项目名称]
@@ -501,6 +501,32 @@
 

展示任意分支某一文件的内容

$ git show <branch-name>:<file-name>
 
+

配置 http 和 socks 代理

+ +
# 查看代理
+$ 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
+

clone 最新一次提交

$ git clone --depth=1 https://github.com/user/repo.git
 
@@ -527,31 +553,6 @@
git reset <file-name>
 

不添加参数,默认是 -mixed

-

配置 http 和 socks 代理

-
# 查看代理
-$ 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 代理