Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git how switch proxy settings for different networks

Tags:

git

github

proxy

I work at a company and from home too using my laptop running Ubuntu Linux. The code is in a github repo. At company I access the network via a http proxy while at home there is no proxy. How to git push/pull in such cases? How to tell git to use proxy when at company and not to use proxy when at home?

This seems different than How to temporarily disable git http proxy, because in my case, I am accessing remote repo in both cases and not a local repo as in that question/answer.

My situation seems to be different than what is described in this question too git-proxy-bypass

What I want is to access my github repo in two ways:

  1. From behind company proxy
  2. From my home network without proxy

I have to do this quite frequently.

like image 429
sandy Avatar asked Mar 14 '26 16:03

sandy


1 Answers

You can either:

  • use a different account and declare your proxy in your global Git settings.
    Those are stored in \Path\To\yourAccount\.gitconfig, which means two different settings depending on your workplace.
  • use a script that you launch automatically when you start your OS, which will:
    • detect if a proxy is needed (try accessing a known url: if it fails, you need to set a proxy with authentication)
    • declare the HTTP(S)_PROXY and NO_PROXY environment variables accordingly.
like image 92
VonC Avatar answered Mar 17 '26 05:03

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!