
Firstly - Check
-
Check if U have global .gitconfig file
-
檢查是否有全局 .gitconfig 文件
-
Usually global .gitconfig will be created in directory /Users/yourAccountName
-
通常情況下全局的.gitconfig文件會在文件夾 /Users/你的用戶名下
-
Such as mine, it is being /Users/robingao
-
我的是/Users/robingao(Just because my account name of my MBP is robingao)
Secondly - Show the code
-
If not exist, it just indecated that you had never config global git configuration.But it happened rarely.
-
如果不存在,說明你從來沒有配置過git的全局配置。但,這種情況極少
-
U can just created it by opening your terminal in spotlight(shotcut: ⌘ + space), and copy and run(just tap ↩︎ button) the code below
-
你可以通過聚焦搜索來打開終端(快捷鍵:⌘ + 空格),復制並運行(回車)下面的代碼
git config --global http.https://github.com.proxy http://127.0.0.1:1080
Thirdly - Description
- U can open the .gitconfig by clicking it, and U can see the text below what was generated just now.
- 你可以打開.gitconfig文件來查看,會顯示剛剛生成的如下文本
[http "https://github.com"]
proxy = http://127.0.0.1:1080
-
The proxy works as a medium between https://github.com and your device
-
代理在你的設備和https://github.com之間充當媒介
-
U must check if your proxy port is 1080. If not, change it into yours.
-
查看你的代理端口是否是1080,如果不是,改成你自己的。
Forthly
- U wanna got all connection through git mediated by your proxy, U might just code
http.proxy.Whole code is shown below - 如果你想所有的git命令都走代理,只需要寫
http.proxy,完整代碼如下
git config --global http.proxy http://127.0.0.1:1080
Fifthly
- It is not the end. U have to run another code below to ensure https connection go through proxy
- 還沒結束。還需要再運行下面的代碼,確保https的連接也走代理
git config --global https.https://github.com.proxy https://127.0.0.1:1080
OR(或者)
git config --global https.proxy https://127.0.0.1:1080
------------------------- MAGIC CODE AREA / 完整代碼 -------------------------
- If U just wanna got configured right now, and have no time to understand it, just run the magic code behind
如果你就想配置完就完事了,沒時間搞懂,那就直接復制運行下面的代碼
git config --global http.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
OR JUST GITHUB PROXY
git config --global http.https://github.com.proxy http://127.0.0.1:1080
git config --global https.https://github.com.proxy https://127.0.0.1:1080
------------------------ SOCKS5 HERE / socks5 代理 ---------------------------------
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080
OR JUST GITHUB PROXY
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
----------------------- UNSET PROXY / 重置代理 --------------------------------
git config --global --unset http.https://github.com.proxy
git config --global --unset https.https://github.com.proxy
OR
git config --global --unset http.proxy
git config --global --unset https.proxy
ANOTHER WAY
- U might open .gitconfig and type the configuration text just like
- 你也可以直接打開.gitcofig文件,直接寫下文本,像這個
[http "https://github.com"]
proxy = http://127.0.0.1:1080
[https "https://github.com"]
proxy = https://127.0.0.1:1080
END
