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
How to do a git config global edit? The global git config is simply a text file, so it can be edited with whatever text editor you choose. Open, edit global git config, save and close, and the changes will take effect the next time you issue a git command. It's that easy.
The . git/config file in each repository is used to store the configuration for that repository, and $HOME/. gitconfig is used to store a per-user configuration as fallback values for the . git/config file. The file /etc/gitconfig can be used to store a system-wide default configuration.
Login to github.com and bring up your account settings by clicking the tools icon. Select SSH Keys from the side menu, then click the Add SSH key button. Name your key something whatever you like, and paste the contents of your clipboard into the Key text box. Finally, hit Add key to save.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With