Sometimes it can be useful and even necessary to configure Git to use a proxy in the global configuration.
It’s a easy as (https://git-scm.com/docs/git-config#git-config-httpproxy) :
git config --global http.proxy host:port
This configuration will then be written in
You will then have something like that :
[user] name = Me email = firstname.lastname@example.org [http] proxy = host:port
Then one day you want to switch and use a different proxy, or none.
But it’s not obvious to configure, regarding the official documentation (https://git-scm.com/docs/git-config).
I could simply unset the proxy if I want to use none, like this :
git config --global --unset http.proxy
I also tried to create aliases to switch to another configuration, like :
git config --global alias.proxy-local 'config --local http.proxy host:port'
git config --global alias.noproxy-local 'config --local http.proxy none'
So I can use ‘git proxy-local’ or ‘git noproxy-local’ depending of the project.
But it could be more practical. By searching further I found a way to configure the proxy depending on the URL. Within the configuration we can use this format to configure options : http.<url>.* (https://git-scm.com/docs/git-config#git-config-httplturlgt).
Some examples are also documented like this :
; HTTP [http] sslVerify [http "https://weak.example.com"] sslVerify = false cookieFile = /tmp/cookie.txt
So that way you can configure a proxy by default, and for some URL use another proxy or none :
; Use a proxy by default [http] proxy = host:port ; Use no proxy on internal server [http "http://myserver.mycompany/"] proxy =
That’s it !