git 设置和取消指定域名代理 - git config proxy
<p><img src="https://img2018.cnblogs.com/blog/1893564/201912/1893564-20191210153314633-298736064.png" alt="git config" loading="lazy"></p><h1 id="firstly---check">Firstly - Check</h1>
<ul>
<li>
<p>Check if U have global .gitconfig file</p>
</li>
<li>
<p>检查是否有全局 <strong>.gitconfig</strong> 文件</p>
</li>
<li>
<p>Usually global .gitconfig will be created in directory <strong>/Users/yourAccountName</strong></p>
</li>
<li>
<p>通常情况下全局的.gitconfig文件会在文件夹 <strong>/Users/你的用户名下</strong></p>
</li>
<li>
<p>Such as mine, it is being <strong>/Users/robingao</strong></p>
</li>
<li>
<p>我的是/Users/robingao(Just because my account name of my MBP is robingao)</p>
</li>
</ul>
<h1 id="secondly---show-the-code">Secondly - Show the code</h1>
<ul>
<li>
<p>If not exist, it just indecated that you had never config global git configuration.But it happened rarely.</p>
</li>
<li>
<p>如果不存在,说明你从来没有配置过git的全局配置。但,这种情况极少</p>
</li>
<li>
<p>U can just created it by opening your terminal in spotlight(shotcut: ⌘ + space), and copy and run(just tap ↩︎ button) the code below</p>
</li>
<li>
<p>你可以通过聚焦搜索来打开终端(快捷键:⌘ + 空格),复制并运行(回车)下面的代码</p>
</li>
</ul>
<pre><code>git config --global http.https://github.com.proxy http://127.0.0.1:1080
</code></pre>
<h1 id="thirdly---description">Thirdly - Description</h1>
<ul>
<li>U can open the .gitconfig by clicking it, and U can see the text below what was generated just now.</li>
<li>你可以打开.gitconfig文件来查看,会显示刚刚生成的如下文本</li>
</ul>
<pre><code>
proxy = http://127.0.0.1:1080
</code></pre>
<ul>
<li>
<p>The proxy works as a medium between https://github.com and your device</p>
</li>
<li>
<p>代理在你的设备和https://github.com之间充当媒介</p>
</li>
<li>
<p>U must check if your proxy port is 1080. If not, change it into yours.</p>
</li>
<li>
<p>查看你的代理端口是否是1080,如果不是,改成你自己的。</p>
</li>
</ul>
<h1 id="forthly">Forthly</h1>
<ul>
<li>U wanna got all connection through git mediated by your proxy, U might just code <code>http.proxy</code>.Whole code is shown below</li>
<li>如果你想所有的git命令都走代理,只需要写<code>http.proxy</code>,完整代码如下</li>
</ul>
<pre><code>git config --global http.proxy http://127.0.0.1:1080
</code></pre>
<h1 id="fifthly">Fifthly</h1>
<ul>
<li>It is not the end. U have to run another code below to ensure https connection go through proxy</li>
<li>还没结束。还需要再运行下面的代码,确保https的连接也走代理</li>
</ul>
<pre><code>git config --global https.https://github.com.proxy https://127.0.0.1:1080
</code></pre>
<p>OR(或者)</p>
<pre><code>git config --global https.proxy https://127.0.0.1:1080
</code></pre>
<hr>
<p>-------------------------MAGIC CODE AREA/完整代码-------------------------</p>
<ul>
<li>If U just wanna got configured right now, and have no time to understand it, just run the magic code behind<br>
如果你就想配置完就完事了,没时间搞懂,那就直接复制运行下面的代码</li>
</ul>
<pre><code>git config --global http.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
</code></pre>
<p>OR JUST GITHUB PROXY</p>
<pre><code>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
</code></pre>
<p>------------------------SOCKS5 HERE /socks5 代理---------------------------------</p>
<pre><code>git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080
</code></pre>
<p>OR JUST GITHUB PROXY</p>
<pre><code>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
</code></pre>
<p>-----------------------UNSET PROXY / 重置代理--------------------------------</p>
<pre><code>git config --global --unset http.https://github.com.proxy
git config --global --unset https.https://github.com.proxy
</code></pre>
<p>OR</p>
<pre><code>git config --global --unset http.proxy
git config --global --unset https.proxy
</code></pre>
<h1 id="another-way">ANOTHER WAY</h1>
<ul>
<li>U might open .gitconfig and type the configuration text just like</li>
<li>你也可以直接打开.gitcofig文件,直接写下文本,像这个</li>
</ul>
<pre><code>
proxy = http://127.0.0.1:1080
proxy = https://127.0.0.1:1080
</code></pre>
<hr>
<p>END</p>
</div>
<div id="MySignature" role="contentinfo">
一个俗人,喜欢编程,偶尔写诗,可能会写歌词<br><br>
来源:https://www.cnblogs.com/rockbean/p/12017010.html
頁:
[1]