Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remote url environment variable

Tags:

git

git-remote

I want to add a submodule with a variable in the path so that everyone can use the same .gitmodules.

ie... git submodule add $USER/pub/repo.git I don't want $USER to expand inside .gitmodules. I tried git submodule add '$USER/pub/repo.git' but it cannot find the repo. I see the same behavior when trying to add a remote with an env variable.

like image 464
EncryptedWatermelon Avatar asked Aug 07 '19 13:08

EncryptedWatermelon


1 Answers

It's impossible because git doesn't expand environment variables in URLs.

To do what you want use git config --global url.<base>.insteadOf to substitute URLs on the fly. Everyone in your team has to set URL replacement:

git config --global url.<new-url>.insteadOf <old-url>

See more examples in https://stackoverflow.com/search?q=%5Bgit-submodules%5D+insteadof

like image 54
phd Avatar answered Sep 27 '22 23:09

phd