Skip to content

Instantly share code, notes, and snippets.

@scalaview
Forked from evantoli/GitConfigHttpProxy.md
Created October 21, 2020 13:20

Revisions

  1. @evantoli evantoli revised this gist Jul 30, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion GitConfigHttpProxy.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # Configure Git to use a proxy

    ##In Brief
    ## In Brief

    You may need to configure a proxy server if you're having trouble cloning
    or fetching from a remote repository or getting an error
  2. @evantoli evantoli revised this gist Jan 12, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion GitConfigHttpProxy.md
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,7 @@ git config --global http.https://domain.com.proxy http://proxyUsername:proxyPass
    git config --global http.https://domain.com.sslVerify false
    ```

    Setting `http.<url>.sslVerify=false` may help you quickly get going if your worklplace
    Setting `http.<url>.sslVerify` to `false` may help you quickly get going if your workplace
    employs man-in-the-middle HTTPS proxying. Longer term, you could get the
    root CA that they are applying to the certificate chain
    and specify it with either `http.sslCAInfo` or `http.sslCAPath`.
  3. @evantoli evantoli revised this gist Jan 12, 2016. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions GitConfigHttpProxy.md
    Original file line number Diff line number Diff line change
    @@ -19,6 +19,11 @@ git config --global http.https://domain.com.proxy http://proxyUsername:proxyPass
    git config --global http.https://domain.com.sslVerify false
    ```

    Setting `http.<url>.sslVerify=false` may help you quickly get going if your worklplace
    employs man-in-the-middle HTTPS proxying. Longer term, you could get the
    root CA that they are applying to the certificate chain
    and specify it with either `http.sslCAInfo` or `http.sslCAPath`.

    See also the [git-config](https://git-scm.com/docs/git-config) documentation, especially the following
    sections if you're having HTTPS/SSL issues

  4. @evantoli evantoli revised this gist Jan 12, 2016. 1 changed file with 10 additions and 8 deletions.
    18 changes: 10 additions & 8 deletions GitConfigHttpProxy.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    # In Brief
    # Configure Git to use a proxy

    ##In Brief

    You may need to configure a proxy server if you're having trouble cloning
    or fetching from a remote repository or getting an error
    @@ -27,21 +29,21 @@ sections if you're having HTTPS/SSL issues
    * `http.sslKey`
    * `http.sslCertPasswordProtected`

    # In Detail
    ## In Detail

    ## Configure the proxy
    ### Configure the proxy

    You can configure these globally in your user `~/.gitconfig` file using the `--global` switch, or local to a repository in its `.git/config` file.

    ### Setting a global proxy
    #### Setting a global proxy

    Configure a global proxy if all access to all repos require this proxy

    ```
    git config --global http.proxy http://proxyUsername:proxyPassword@proxy.server.com:port
    ```

    ### URL specific proxy
    #### URL specific proxy

    If you wish to specify that a proxy should be used for just
    some URLs that specify the URL as a git config subsection
    @@ -59,7 +61,7 @@ Which will result in the following in the `~/.gitconfig` file:
    proxy = http://proxyUsername:proxyPassword@proxy.server.com:port
    ```

    ### Handle subsequent SSL protocol errors
    #### Handle subsequent SSL protocol errors

    If you're still having trouble cloning or fetching and are now getting
    an `unable to access 'https://...': Unknown SSL protocol error in connection to ...:443` then
    @@ -93,7 +95,7 @@ Which will result in the following in the `~/.gitconfig` file:
    sslVerify = false
    ```

    ## Show current configuration
    ### Show current configuration

    To show the current configuration of all `http` sections

    @@ -108,7 +110,7 @@ the `--global` and see all current config:
    git config --get-regexp http.*
    ```

    ## Unset a proxy or SSL verification
    ### Unset a proxy or SSL verification

    Use the `--unset` flag to remove configuration being specific about the
    property -- for example whether it was `http.proxy` or `http.<url>.proxy`.
  5. @evantoli evantoli revised this gist Jan 12, 2016. 1 changed file with 26 additions and 0 deletions.
    26 changes: 26 additions & 0 deletions GitConfigHttpProxy.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,34 @@
    # In Brief

    You may need to configure a proxy server if you're having trouble cloning
    or fetching from a remote repository or getting an error
    like `unable to access '...' Couldn't resolve host '...'`.

    Consider something like:

    ```
    git config --global http.proxy http://proxyUsername:proxyPassword@proxy.server.com:port
    ```

    Or for a specific domain, something like:

    ```
    git config --global http.https://domain.com.proxy http://proxyUsername:proxyPassword@proxy.server.com:port
    git config --global http.https://domain.com.sslVerify false
    ```

    See also the [git-config](https://git-scm.com/docs/git-config) documentation, especially the following
    sections if you're having HTTPS/SSL issues

    * `http.sslVerify`
    * `http.sslCAInfo`
    * `http.sslCAPath`
    * `http.sslCert`
    * `http.sslKey`
    * `http.sslCertPasswordProtected`

    # In Detail

    ## Configure the proxy

    You can configure these globally in your user `~/.gitconfig` file using the `--global` switch, or local to a repository in its `.git/config` file.
  6. @evantoli evantoli revised this gist Jan 12, 2016. 1 changed file with 47 additions and 22 deletions.
    69 changes: 47 additions & 22 deletions GitConfigHttpProxy.md
    Original file line number Diff line number Diff line change
    @@ -3,42 +3,37 @@ You may need to configure a proxy server if you're having trouble cloning
    or fetching from a remote repository or getting an error
    like `unable to access '...' Couldn't resolve host '...'`.

    # Configure the proxy
    ## Configure the proxy

    ## One proxy for all http and https repo access
    You can configure these globally in your user `~/.gitconfig` file using the `--global` switch, or local to a repository in its `.git/config` file.

    ### Setting a global proxy

    Configure a global proxy if all access to all repos require this proxy

    ```
    git config --global http.proxy http://proxyUsername:proxyPassword@proxy.server.com:port
    git config --global https.proxy https://proxyUsername:proxyPassword@proxy.server.com:port
    ```

    ## Separate rules for proxies specific to URLs
    ### URL specific proxy

    If you wish to specify that a proxy should be used for just
    some URLs that specify the URL as a git config subsection
    using `sectioname.subsectionname.key` notation:
    using `http.<url>.key` notation:

    ```
    git config --global http.http://domain.com.proxy http://proxyUsername:proxyPassword@proxy.server.com:port
    git config --global https.https://domain.com.proxy https://proxyUsername:proxyPassword@proxy.server.com:port
    git config --global http.https://domain.com.proxy http://proxyUsername:proxyPassword@proxy.server.com:port
    ```

    The above seems strange to me but it seems that the convention must be
    that everything between the first and last dots in `http.http://domain.com.proxy`
    becomes the subsection name. Thus the above commands result in the following
    sections in the global `~/.gitconfig`
    Which will result in the following in the `~/.gitconfig` file:

    ```
    [http]
    [http "http://domain.com"]
    [http "https://domain.com"]
    proxy = http://proxyUsername:proxyPassword@proxy.server.com:port
    [https "https://domain.com"]
    proxy = https://proxyUsername:proxyPassword@proxy.server.com:port
    ```

    ## Handle subsequent SSL protocol errors
    ### Handle subsequent SSL protocol errors

    If you're still having trouble cloning or fetching and are now getting
    an `unable to access 'https://...': Unknown SSL protocol error in connection to ...:443` then
    @@ -56,18 +51,48 @@ repository's `.git/config` by doing. Notice the absence of the `--global`
    git config http.sslVerify false
    ```

    # List the currently set proxies and SSL verification
    If you choose to make it global then limit it to a URL using
    the `http.<url>.sslVerify` notation:

    ```
    git config --global http.https://domain.com.sslVerify false
    ```

    Which will result in the following in the `~/.gitconfig` file:

    ```
    git config --global --get http.proxy
    git config --global --get https.proxy
    git config --get http.sslVerify
    [http]
    [http "https://domain.com"]
    proxy = http://proxyUsername:proxyPassword@proxy.server.com:port
    sslVerify = false
    ```

    # Unset a proxy or SSL verification
    ## Show current configuration

    To show the current configuration of all `http` sections

    ```
    git config --global --get-regexp http.*
    ```

    If you are in a locally cloned repository folder then you drop
    the `--global` and see all current config:

    ```
    git config --get-regexp http.*
    ```

    ## Unset a proxy or SSL verification

    Use the `--unset` flag to remove configuration being specific about the
    property -- for example whether it was `http.proxy` or `http.<url>.proxy`.
    Consider using any of the following:

    ```
    git config --global --unset http.proxy
    git config --global --unset https.proxy
    git config --unset https.proxy
    git config --global --unset http.https://domain.com.proxy
    git config --global --unset http.sslVerify
    git config --global --unset http.https://domain.com.sslVerify
    ```
  7. @evantoli evantoli created this gist Jan 12, 2016.
    73 changes: 73 additions & 0 deletions GitConfigHttpProxy.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,73 @@

    You may need to configure a proxy server if you're having trouble cloning
    or fetching from a remote repository or getting an error
    like `unable to access '...' Couldn't resolve host '...'`.

    # Configure the proxy

    ## One proxy for all http and https repo access

    Configure a global proxy if all access to all repos require this proxy

    ```
    git config --global http.proxy http://proxyUsername:proxyPassword@proxy.server.com:port
    git config --global https.proxy https://proxyUsername:proxyPassword@proxy.server.com:port
    ```

    ## Separate rules for proxies specific to URLs

    If you wish to specify that a proxy should be used for just
    some URLs that specify the URL as a git config subsection
    using `sectioname.subsectionname.key` notation:

    ```
    git config --global http.http://domain.com.proxy http://proxyUsername:proxyPassword@proxy.server.com:port
    git config --global https.https://domain.com.proxy https://proxyUsername:proxyPassword@proxy.server.com:port
    ```

    The above seems strange to me but it seems that the convention must be
    that everything between the first and last dots in `http.http://domain.com.proxy`
    becomes the subsection name. Thus the above commands result in the following
    sections in the global `~/.gitconfig`

    ```
    [http]
    [http "http://domain.com"]
    proxy = http://proxyUsername:proxyPassword@proxy.server.com:port
    [https "https://domain.com"]
    proxy = https://proxyUsername:proxyPassword@proxy.server.com:port
    ```

    ## Handle subsequent SSL protocol errors

    If you're still having trouble cloning or fetching and are now getting
    an `unable to access 'https://...': Unknown SSL protocol error in connection to ...:443` then
    you may decide to switch off SSL verification for the single operation
    by using the `-c http.sslVerify=false` option

    ```
    git -c http.sslVerify=false clone https://domain.com/path/to/git
    ```

    Once cloned, you may decide set this for just this cloned
    repository's `.git/config` by doing. Notice the absence of the `--global`

    ```
    git config http.sslVerify false
    ```

    # List the currently set proxies and SSL verification

    ```
    git config --global --get http.proxy
    git config --global --get https.proxy
    git config --get http.sslVerify
    ```

    # Unset a proxy or SSL verification

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