{"id":1244,"date":"2020-06-26T13:11:18","date_gmt":"2020-06-26T05:11:18","guid":{"rendered":"https:\/\/freesilo.com\/?p=1244"},"modified":"2020-06-26T13:11:18","modified_gmt":"2020-06-26T05:11:18","slug":"git%e4%bd%bf%e7%94%a8%e4%bb%a3%e7%90%86%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84%e8%ae%be%e7%bd%ae%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/freesilo.com\/?p=1244","title":{"rendered":"git\u4f7f\u7528\u4ee3\u7406\u670d\u52a1\u5668\u7684\u8bbe\u7f6e\u65b9\u6cd5"},"content":{"rendered":"<p>\u5206\u8fa8\u9700\u8981\u8bbe\u7f6e\u7684\u4ee3\u7406<br \/>\nHTTP \u5f62\u5f0f\uff1a<br \/>\ngit clone https:\/\/github.com\/owner\/git.git<\/p>\n<p>SSH \u5f62\u5f0f\uff1a<br \/>\ngit clone git@github.com:owner\/git.git<\/p>\n<p><a href=\"http:\/\/blog.useasp.net\/tags\/Git\" rel=\"tag\">Git<\/a>\u652f\u6301\u56db\u79cd\u534f\u8bae<sup>1<\/sup>\uff0c\u800c\u9664\u672c\u5730\u4f20\u8f93\u5916\uff0c\u8fd8\u6709\uff1agit:\/\/, ssh:\/\/, \u57fa\u4e8eHTTP\u534f\u8bae\uff0c\u8fd9\u4e9b\u534f\u8bae\u53c8\u88ab\u5206\u4e3a\u54d1\u534f\u8bae\uff08HTTP\u534f\u8bae\uff09\u548c\u667a\u80fd\u4f20\u8f93\u534f\u8bae\u3002\u5bf9\u4e8e\u8fd9\u4e9b\u534f\u8bae\uff0c\u8981\u4f7f\u7528\u4ee3\u7406\u7684\u8bbe\u7f6e\u4e5f\u6709\u4e9b\u5dee\u5f02\uff1a<\/p>\n<ol>\n<li>\u4f7f\u7528<code>git\u534f\u8bae<\/code>\u65f6\uff0c\u8bbe\u7f6e\u4ee3\u7406\u9700\u8981\u914d\u7f6e<code>core.gitproxy<\/code><\/li>\n<li>\u4f7f\u7528<code>HTTP\u534f\u8bae<\/code>\u65f6\uff0c\u8bbe\u7f6e\u4ee3\u7406\u9700\u8981\u914d\u7f6e<code>http.proxy<\/code><\/li>\n<li>\u800c\u662f\u7528<code>ssh\u534f\u8bae<\/code>\u65f6\uff0c\u4ee3\u7406\u9700\u8981\u914d\u7f6essh\u7684<code>ProxyCommand<\/code>\u53c2\u6570<\/li>\n<\/ol>\n<h3 id=\"1-Http\u4ee3\u7406\u8bbe\u7f6e\">1.Http\u5f62\u5f0f \u4ee3\u7406\u8bbe\u7f6e<\/h3>\n<h6>\u8d70 HTTP \u4ee3\u7406<\/h6>\n<div class=\"highlight highlight-source-shell\">\n<pre>git config --global http.proxy <span class=\"pl-s\"><span class=\"pl-pds\">\"<\/span>http:\/\/127.0.0.1:8080<span class=\"pl-pds\">\"<\/span><\/span>\r\ngit config --global https.proxy <span class=\"pl-s\"><span class=\"pl-pds\">\"<\/span>http:\/\/127.0.0.1:8080<span class=\"pl-pds\">\"<\/span><\/span><\/pre>\n<\/div>\n<h6><a id=\"user-content-\u8d70-socks5-\u4ee3\u7406\u5982-shadowsocks\" class=\"anchor\" href=\"https:\/\/gist.github.com\/chuyik\/02d0d37a49edc162546441092efae6a1#%E8%B5%B0-socks5-%E4%BB%A3%E7%90%86%E5%A6%82-shadowsocks\" aria-hidden=\"true\"><\/a>\u8d70 socks5 \u4ee3\u7406\uff08\u5982 Shadowsocks\uff09<\/h6>\n<div class=\"highlight highlight-source-shell\">\n<pre>git config --global http.proxy <span class=\"pl-s\"><span class=\"pl-pds\">\"<\/span>socks5:\/\/127.0.0.1:1080<span class=\"pl-pds\">\"<\/span><\/span>\r\ngit config --global https.proxy <span class=\"pl-s\"><span class=\"pl-pds\">\"<\/span>socks5:\/\/127.0.0.1:1080<span class=\"pl-pds\">\"<\/span><\/span><\/pre>\n<\/div>\n<h6><a id=\"user-content-\u53d6\u6d88\u8bbe\u7f6e\" class=\"anchor\" href=\"https:\/\/gist.github.com\/chuyik\/02d0d37a49edc162546441092efae6a1#%E5%8F%96%E6%B6%88%E8%AE%BE%E7%BD%AE\" aria-hidden=\"true\"><\/a>\u53d6\u6d88\u8bbe\u7f6e<\/h6>\n<div class=\"highlight highlight-source-shell\">\n<pre>git config --global --unset http.proxy\r\ngit config --global --unset https.proxy<\/pre>\n<\/div>\n<ul>\n<li>\u547d\u4ee4\uff1a<code> git config --global http.proxy http:\/\/127.0.0.1:1087<\/code><\/li>\n<li>\u8bf4\u660e\uff1a \u5168\u5c40\u8bbe\u7f6e http \u4ee3\u7406<\/li>\n<li>\u6b64\u547d\u4ee4\u4fee\u6539\u7684\u6587\u4ef6\u4e3a <code> C:\\Users\\\u7528\u6237\u540d\\.gitconfig<\/code> (Windows \u73af\u5883\u4e0b)<\/li>\n<li>\u53d6\u6d88\u8bbe\u7f6e <code>git config --global --unset http.proxy<\/code><\/li>\n<\/ul>\n<h3 id=\"2-\u8bbe\u7f6eSSH\u4ee3\u7406\">2. SSH \u5f62\u5f0f\u4ee3\u7406\u8bbe\u7f6e<\/h3>\n<h4 id=\"2-1\u8bbe\u7f6e\u672c\u5730http\u6216sockt\u4ee3\u7406\">2.1 \u8bbe\u7f6e\u672c\u5730 http \u6216 socks\u4ee3\u7406\uff08Windows\uff09<\/h4>\n<p>\u4fee\u6539\u7684\u6587\u4ef6\u4e3a C:\\Users\\\u7528\u6237\u540d\\.ssh\\config (\u4e0d\u5b58\u5728\u81ea\u884c\u521b\u5efa)<br \/>\n\u914d\u7f6e\u65b9\u68481\uff1a<\/p>\n<pre><code>\r\nHost github.com *.github.com\r\n    User git\r\n    # SSH\u9ed8\u8ba4\u7aef\u53e322\uff0c HTTPS\u9ed8\u8ba4\u7aef\u53e3443\r\n    Port 22\r\n    Hostname %h\r\n    # \u8fd9\u91cc\u653e\u4f60\u7684SSH\u79c1\u94a5\r\n    IdentityFile ~\\.ssh\\id_rsa\r\n    # \u8bbe\u7f6e\u4ee3\u7406, 127.0.0.1:1080 \u6362\u6210\u4f60\u81ea\u5df1\u4ee3\u7406\u8f6f\u4ef6\u76d1\u542c\u7684\u672c\u5730\u5730\u5740\r\n    # HTTPS\u4f7f\u7528-H\uff0cSOCKS\u4f7f\u7528-S\r\n    ProxyCommand connect -S 127.0.0.1:1080 %h %p\r\n<\/code><\/pre>\n<p>\u914d\u7f6e\u65b9\u68482\uff1a<\/p>\n<pre><code>\r\n# \u8fd9\u91cc\u7684 -a none \u662f NO-AUTH \u6a21\u5f0f\uff0c\u53c2\u89c1 <a href=\"https:\/\/bitbucket.org\/gotoh\/connect\/wiki\/Home\">https:\/\/bitbucket.org\/gotoh\/connect\/wiki\/Home<\/a> \u4e2d\u7684 More detail \u4e00\u8282 \r\nProxyCommand connect -S 127.0.0.1:1080 -a none %h %p \r\nHost github.com \r\nUser git \r\nPort 22 \r\nHostname github.com \r\n# \u6ce8\u610f\u4fee\u6539\u8def\u5f84\u4e3a\u4f60\u7684\u8def\u5f84 \r\nIdentityFile \"C:\\Users\\\u7528\u6237\u540d\\.ssh\\id_rsa\" \r\nTCPKeepAlive yes \r\nHost ssh.github.com \r\nUser git \r\nPort 443 \r\nHostname ssh.github.com \r\n# \u6ce8\u610f\u4fee\u6539\u8def\u5f84\u4e3a\u4f60\u7684\u8def\u5f84 \r\nIdentityFile \"C:\\Users\\\u7528\u6237\u540d\\.ssh\\id_rsa\" \r\nTCPKeepAlive yes\r\n<\/code><\/pre>\n<p><strong>\u8bf4\u660e\uff1a<code>connect.exe<\/code> \u5df2\u7ecf\u5728 Git \u4e2d\u9884\u7f6e\u4e86\uff0c\u65e0\u9700\u518d\u6b21\u4e0b\u8f7d\u5b89\u88c5\u3002connect \u5177\u4f53\u547d\u4ee4\u53c2\u6570\u53c2\u8003<a href=\"https:\/\/bitbucket.org\/gotoh\/connect\/wiki\/Home\" target=\"_blank\" rel=\"nofollow noopener ugc noreferrer\">\u5b98\u65b9\u8bf4\u660e\u6587\u6863<\/a><\/strong><br \/>\n\u8be5\u65b9\u5f0f\u7684\u914d\u7f6e\u4e2d\uff0c\u5982\u679c Host \u8bbe\u7f6e\u4e3a *\uff0c\u90a3\u4e48 Host * \u5bf9\u5e94\u7684\u914d\u7f6e\u4f1a\u88ab\u5e94\u7528\u5230\u6240\u6709\u6ca1\u6709\u72ec\u7acb\u914d\u7f6e \u7684 ssh \u8fde\u63a5\u4e2d\uff0c\u5305\u62ec\u4f7f\u7528\u4e86 ssh \u534f\u8bae\u7684 git \u64cd\u4f5c\u3002<\/p>\n<h4 id=\"2-2\u5176\u4ed6\u8bbe\u7f6e\u65b9\u6cd5\">2.2 \u5176\u4ed6\u8bbe\u7f6e\u65b9\u6cd5\uff08Linux\\MacOS\uff09<\/h4>\n<div class=\"vditor-copy\">\u5728 ~\/.ssh\/config \u6587\u4ef6\u4e2d\u52a0\u5165\u4ee5\u4e0b\u914d\u7f6e:<\/div>\n<pre><code class=\"highlight-chroma\">   # \u5fc5\u987b\u662f github.com\r\n   Host github.com\r\n   HostName github.com\r\n   User git\r\n   # \u8d70 HTTP \u4ee3\u7406\r\n   # ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=8080\r\n   # \u8d70 socks5 \u4ee3\u7406\r\n   # ProxyCommand nc -v -x 127.0.0.1:1080 %h %p\r\n<\/code><\/pre>\n<p>\u6b64\u65b9\u6cd5\u8d70 socks\u4ee3\u7406\u8bbe\u7f6e\u6709\u6548\uff0chttp \u4ee3\u7406\u9a8c\u8bc1\u4f1a\u62a5\u9519<\/p>\n<p>\u53c2\u8003\u6587\u7ae0\u5730\u5740<\/p>\n<p><a href=\"https:\/\/upupming.site\/2019\/05\/09\/git-ssh-socks-proxy\/\">https:\/\/upupming.site\/2019\/05\/09\/git-ssh-socks-proxy\/<\/a><br \/>\n<a href=\"https:\/\/link.hacpai.com\/forward?goto=https%3A%2F%2Fbitbucket.org%2Fgotoh%2Fconnect%2Fwiki%2FHome\" target=\"_blank\" rel=\"nofollow noopener ugc noreferrer\">https:\/\/bitbucket.org\/gotoh\/connect\/wiki\/Home<\/a><br \/>\n<a href=\"https:\/\/link.hacpai.com\/forward?goto=https%3A%2F%2Fgist.github.com%2Fchuyik%2F02d0d37a49edc162546441092efae6a1\" target=\"_blank\" rel=\"nofollow noopener ugc noreferrer\">https:\/\/gist.github.com\/chuyik\/02d0d37a49edc162546441092efae6a1<\/a><br \/>\n<a href=\"https:\/\/link.hacpai.com\/forward?goto=https%3A%2F%2Fwww.hi-linux.com%2Fposts%2F11850.html\" target=\"_blank\" rel=\"nofollow noopener ugc noreferrer\">https:\/\/www.hi-linux.com\/posts\/11850.html<\/a><br \/>\n<a href=\"https:\/\/blog.systemctl.top\/2017\/2017-09-28_set-proxy-for-git-and-ssh-with-socks5\/\">https:\/\/blog.systemctl.top\/2017\/2017-09-28_set-proxy-for-git-and-ssh-with-socks5\/<\/a><br \/>\n<a href=\"https:\/\/gist.github.com\/chuyik\/02d0d37a49edc162546441092efae6a1\">https:\/\/gist.github.com\/chuyik\/02d0d37a49edc162546441092efae6a1<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5206\u8fa8\u9700\u8981\u8bbe\u7f6e\u7684\u4ee3\u7406 HTTP \u5f62\u5f0f\uff1a git clone https:\/\/git&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/freesilo.com\/?p=1244\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["post-1244","post","type-post","status-publish","format-standard","hentry","category-git"],"_links":{"self":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/1244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1244"}],"version-history":[{"count":4,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/1244\/revisions"}],"predecessor-version":[{"id":1248,"href":"https:\/\/freesilo.com\/index.php?rest_route=\/wp\/v2\/posts\/1244\/revisions\/1248"}],"wp:attachment":[{"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/freesilo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}