I would like to use different user.name
/user.email
in git depending on remote url. I've tried with gitlab and gitea instances without success.
I've tried to use includeIf
following documentation.
~/.gitconfig
[includeIf "hasconfig:remote.*.url:https://git.example.com/**"]
path = ~/.gitconfig-git.example.com
~/.gitconfig-git.example.com
[user]
email = admin@example.com
name = Admin
Inside a git repository, I am unable to get the user.
> git config --get remote.origin.url
https://git.example.com/organisation/repository
> git config --get user.email
> git config --get user.name
What am I doing wrong ?
I mentioned the 2.36 hasconfig:remote.*.url:
new setting as a new value for the conditional inclusion mechanism of configuration files using "[includeIf <condition>]
"
That means, if your Git is not at 2.36, said new condition value would just be ignored.
Marcos Pereira suggests in the comments:
Even after updating Git, it took some trial and error to get it to match GitLab SSH URLs.
For those looking for that, this is the pattern that worked for me:[includeIf "hasconfig:remote.*.url:git@gitlab.com:*/**"].
**/**
also worked, any other combination I tried didn't.