3

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.

Community
  • 1
  • 1
sandy
  • 53
  • 8
  • Are you not using two different configs in the two different machines? – itsazzad Jan 15 '17 at 05:46
  • It is the same machine, my laptop. – sandy Jan 15 '17 at 07:21
  • May you make two scripts to be run manually to add or remove remote origin proxy? – itsazzad Jan 15 '17 at 08:37
  • You can write a script A to set up the company proxy, and a script B to set up no proxy. Then, write a wrapper script to be called when your laptop connects to a wifi (refer to https://wiki.ubuntu.com/OnNetworkConnectionRunScript), and this script should programmatically run script A or B. – zhanxw Sep 25 '18 at 02:59

1 Answers1

0

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:
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • my machine is Ubuntu Linux. – sandy Jan 15 '17 at 07:21
  • @sandy that works with Linux as well: your .bashrc can trigger the script whenever you open a shell. Or your .profile can trigger the script whenever you log on. – VonC Jan 15 '17 at 07:28
  • but you have said to use a different account, which may be error prone and cumbersome. – sandy Jan 15 '17 at 08:09
  • @sandy I said "either" (you can either do A or B): if you don't want to use a separate account, you can create a script which will test internet access and determine, when you open a new session, if proxy needs to be set or not. – VonC Jan 15 '17 at 08:10