Robbo_UK
Robbo_UK

Reputation: 12149

git config proxy for a project with submodules

I have the following project setup

ProjectA  
    -- [sub moduleB]
       -- file1
       -- file2 etc
    -- [sub moduleC]
  --file1
  --file2
  --etc

ProjectA is its own project. As are the submodules. Each have their own files and folders and git repository. However the problem I have is that due to company restrictions the stuff in the submodules requires me to connect to it via a proxy. e.g. ProjectA is hosted internally but the submodules are not. Think of the submodules as like external plugins for a bigger app.

I currently get around this by manually setting the proxy.

So inside projectA I clear the proxy setting by typing

git config --global http.proxy ""

When im in the submodule I then set the proxy

git config --global http.proxy http://<proxy url>:8080

Can I configure git to remember the proxy on a folder level? So I don't have to keep remembering (and sometimes forgetting) to run this config command. I would like to just do it once and then forget about it.

Upvotes: 1

Views: 2874

Answers (1)

Andrew C
Andrew C

Reputation: 14863

Disclaimer - I do not have an environment similar to yours where I can test this

When you configure something like

git config --global

The --global says "put this configuration value in the .gitconfig file in my home directory". Git applies your home version of .gitconfig to all repositories you access. If you were to instead configure like

git config http.proxy http://your.proxy:8080

It would place the configuration entry in the current repository config file, which is located in $REPO/.git/config. So in your instance having http.proxy set in each submodule, but having http.proxy have no value in the superproject or in your home config might do the trick.

So unset it globally

git config --global --unset http.proxy 

Then navigate to each submodule and do

git config http.proxy http://your.proxy:8080

Upvotes: 5

Related Questions