This is how I set up my git config to assume different identities depending on which directory I'm working in.
In ~/.gitconfig
:
[core]
# sshCommand = ssh -i ~/.ssh/SOME_RSA_PRIVATE_KEY
[user]
name = Andrew Kemm
[init]
templatedir = /Users/andrewkemm/.git-template
[includeIf "gitdir:~/dev/internal/"]
path = ~/dev/internal/.gitconfig
[includeIf "gitdir:~/dev/other/"]
path = ~/dev/other/.gitconfig
# Per client config
# [includeIf "gitdir:~/dev/client/CLIENT_NAME/"]
# path = ~/dev/client/CLIENT_NAME/.gitconfig
Note the includeIf
s associating a directory with another .gitconfig
file.
Here is an example of one of those other .gitconfig
files:
[core]
sshCommand = ssh -i ~/.ssh/id_rsa_thoughtworks
[user]
email = "andrew.kemm@thoughtworks.com"
Here, we specify which rsa token and email address to use.