2

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 ?

Bhasher
  • 68
  • 2
  • 7
  • 3
    Probably nothing: this new `includeIf` condition is in Git 2.36, just released, but not in any older version of Git. Run `git version` (or `git --version`) to find out which Git version *you're* using. – torek May 01 '22 at 16:51

1 Answers1

2

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250