I use gitlab.com for my company work, and github.com for my personal work. I've read lots of threads, lots of topics about identity problem and yet, I'm still not able to understand why it's not working from me.
I have a ~/.ssh/config
file as follow
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/perso_id_rsa
Host gitlab
HostName gitlab.com
User git
IdentityFile ~/.ssh/id_rsa
And a master ~/.gitconfig
[user]
email = my_company_address
name = my_company_name
[includeIf "gitdir:~/Workspace/perso"]
path = ~/Workspace/perso/.gitconfig
And a ~/Workspace/perso/.gitconfig
[user]
email = my_perso_email
name = my_pseudo
When I'm making commits from my perso project in ~/Workspace/perso/my_perso_project, the commit author is my company address (the commit is pushed to github without problem).
Can somebody help ?
Thanks
Your includeif is wrong. gitdir:~/Workspace/perso
is not the .git
dir, and doesn't have the search flag. See the git config
docs for includeif,
If the pattern ends with
/
,**
will be automatically added. For example, the patternfoo
/ becomesfoo/**
. In other words, it matches "foo" and everything inside, recursively.
Either name the specific git dir you're checking for or tell Git you mean any git dir in that entire subtree:
[includeIf "gitdir:~/Workspace/perso/.git"]
path = ~/Workspace/perso/.gitconfig
or
[includeIf "gitdir:~/Workspace/perso/**"]
path = ~/Workspace/perso/.gitconfig
or
[includeIf "gitdir:~/Workspace/perso/"]
path = ~/Workspace/perso/.gitconfig