Skip to content

Instantly share code, notes, and snippets.

@CraKeyBoy
Forked from chuyik/README.md
Created May 8, 2020 15:24
Show Gist options
  • Select an option

  • Save CraKeyBoy/11da7183c62d47cc0721d60e871f8dbc to your computer and use it in GitHub Desktop.

Select an option

Save CraKeyBoy/11da7183c62d47cc0721d60e871f8dbc to your computer and use it in GitHub Desktop.

Revisions

  1. @chuyik chuyik revised this gist Jun 11, 2017. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    ## 分辨 git clone 需要设置的代理
    ## 分辨需要设置的代理

    - HTTP 形式:
    https://github.com/owner/git.git
    > git clone https://github.com/owner/git.git
    - SSH 形式:
    [email protected]:owner/git.git
    > git clone [email protected]:owner/git.git
    ## HTTP 形式
    ## 一、HTTP 形式
    ### 走 HTTP 代理

    ```bash
    @@ -27,7 +27,7 @@ git config --global --unset http.proxy
    git config --global --unset https.proxy
    ```

    ## SSH 形式
    ## 二、SSH 形式

    修改 `~/.ssh/config` 文件(不存在则新建):

  2. @chuyik chuyik revised this gist Jun 11, 2017. 1 changed file with 19 additions and 14 deletions.
    33 changes: 19 additions & 14 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,31 +1,36 @@
    # 分辨 git clone 需要设置的代理
    HTTP 形式:
    https://github.com/owner/git.git
    SSH 形式:
    [email protected]:owner/git.git

    # HTTP 形式
    ## 走 HTTP 代理
    ```
    ## 分辨 git clone 需要设置的代理

    - HTTP 形式:
    https://github.com/owner/git.git
    - SSH 形式:
    [email protected]:owner/git.git

    ## HTTP 形式
    ### 走 HTTP 代理

    ```bash
    git config --global http.proxy "http://127.0.0.1:8080"
    git config --global https.proxy "http://127.0.0.1:8080"
    ```

    ## 走 socks5 代理(如 Shadowsocks)
    ```
    ### 走 socks5 代理(如 Shadowsocks)

    ```bash
    git config --global http.proxy "socks5://127.0.0.1:1080"
    git config --global https.proxy "socks5://127.0.0.1:1080"
    ```

    ## 取消设置
    ```
    ### 取消设置

    ```bash
    git config --global --unset http.proxy
    git config --global --unset https.proxy
    ```

    # SSH 形式
    ## SSH 形式

    修改 `~/.ssh/config` 文件(不存在则新建):

    ```
    # 必须是 github.com
    Host github.com
  3. @chuyik chuyik created this gist Jun 11, 2017.
    38 changes: 38 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    # 分辨 git clone 需要设置的代理
    HTTP 形式:
    https://github.com/owner/git.git
    SSH 形式:
    [email protected]:owner/git.git

    # HTTP 形式
    ## 走 HTTP 代理
    ```
    git config --global http.proxy "http://127.0.0.1:8080"
    git config --global https.proxy "http://127.0.0.1:8080"
    ```

    ## 走 socks5 代理(如 Shadowsocks)
    ```
    git config --global http.proxy "socks5://127.0.0.1:1080"
    git config --global https.proxy "socks5://127.0.0.1:1080"
    ```

    ## 取消设置
    ```
    git config --global --unset http.proxy
    git config --global --unset https.proxy
    ```

    # SSH 形式

    修改 `~/.ssh/config` 文件(不存在则新建):
    ```
    # 必须是 github.com
    Host github.com
    HostName github.com
    User git
    # 走 HTTP 代理
    # ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=8080
    # 走 socks5 代理(如 Shadowsocks)
    # ProxyCommand nc -v -x 127.0.0.1:1080 %h %p
    ```