Using git behind a HTTP or socks5 proxy.


If you are using git behind a HTTP or socks5 proxy, you may need to pass the proxy configuration parameter to the git command. This allows you to clone, push, or execute any other git command behind a proxy without any issue.

To push, clone, or execute any git command while using a HTTP or socks5 proxy, you pass a configuration parameter to git command using the -c flag.

The -c flag parameter takes the form: -c <name>=<value>. Example using HTTP proxy:


┌──(user@ubuntu)-[~/Documents/projects/code/some-code]
└─$ git -c http.proxy=http://10.186.159.27:8000 push
Enumerating objects: 20, done.
Counting objects: 100% (20/20), done.
Delta compression using up to 4 threads
Compressing objects: 100% (13/13), done.
Writing objects: 100% (15/15), 1.49 KiB | 253.00 KiB/s, done.
Total 15 (delta 4), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (4/4), completed with 2 local objects.
To https://github.com/github-user-username/repo.git
   ae3c015..3690ff9  main -> main

┌──(user@ubuntu)-[~/Documents/projects/code/some-code]
└─$ 

You can execute the following command if you are using socks5 proxy. The h in socks5h means that the host name will be resolved using the proxy.


┌──(user@ubuntu)-[~/Documents/projects/code/some-code]
└─$ git -c http.proxy=socks5h://10.186.159.27:8000 push

If your proxy requires username and password authentication, all you need is to add them after the protocol, example:


┌──(user@ubuntu)-[~/Documents/projects/code/some-code]
└─$ git -c http.proxy=socks5h://username:password@10.186.159.27:8000 push

┌──(user@ubuntu)-[~/Documents/projects/code/some-code]
└─$ git -c http.proxy=http://username:password@10.186.159.27:8000 push