Home > Enterprise >  Git user depending on remote url
Git user depending on remote url

Time:05-03

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 = [email protected]
    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 ?

CodePudding user response:

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.

  •  Tags:  
  • git
  • Related