Git

How to set up local or global git proxy

Posted by Java developer blog on November 8, 2020

Overview

In the post, we are going to describe how to set up a local or global git proxy.

Global proxy set up

You could either use the following command to set up a global git proxy:

1
git config --global http.proxy http://PROXY_IP:PROXY_PORT

or configure it manually by editing a file ~/.gitconfig:

1
2
[http]
    proxy = PROXY_IP:PROXY_PORT

In Windows ~/.gitconfig usually corresponds to C:/Users/USER_NAME/.gitconfig.

You can verify your configuration by the following command:

1
git config --global --get http.proxy

Local proxy set up

You could either use the following command when you clone repository to set up local git proxy:

1
git clone <REPOSITORY_URL> --config "http.proxy=PROXY_HOST:PROXY_PORT"

or configure it manually by editing a file .git/config:

1
2
[http]
    proxy = PROXY_HOST:PROXY_PORT

You can verify your configuration by the following command:

1
git config --get http.proxy

Conclusion

We have described how to set up local or global git proxy and verify them.