So right now I have some alias in my ~/.ssh/config
:
Host github_company_a
HostName github.com
Host github_company_b
HostName github.com
and I use the alias directly: git clone git@github_company_a:<...>
.
But recently I discovered the includeif
entry from gitconfig.
Now I've my ~/.gitconfig
like this:
[includeif "gitdir:~/Repos/company_a/"]
path = .gitconfig_company_a
[includeif "gitdir:~/Repos/company_b/"]
path = .gitconfig_company_b
For newo both .gitconfig_company_a
and .gitconfig_company_b
only have entries to configure the name and email:
[user]
name = Foo
email = [email protected]
So now I am wondering: Would it be possible to use a gitconfig file to translate host names to another value?
Example: Let's say I'm at the ~/Repos/company_a/
and cloning something from github: [email protected]:<...>
.
since we have a .gitconfig_company_a
we could setup:
[user]
name = Foo
email = [email protected]
[host github.com]
replace = github_company_a
So when I located at the correct company folder I would NOT need to manually adjust the repository host address to the correct SSH Alias before cloning.
Thank you!