July 24, 2018
To separate work and personal projects, I run different SSH keys and git configs. For example specifying a different SSH key and git email for personal and work projects.
This allows me to clone any project, work or personal and get started straight away.
ssh-keygen -t rsa -C "[email protected]"
When asked for the name give a new file name:
Create an empty file called
Add a host entry pointing to your newly made SSH-key by specifying an IdentityFile.
In this example I am pointing all bitbucket requests to my
id_rsa_work SSH key.
Host bitbucket.org HostName bitbucket.org User git IdentityFile ~/.ssh/id_rsa_work
You need to register your new SSH keys
Create an empty file next to your
.gitconfig file e.g.
Here you can specify the custom attributes you need.
[user] name = Jonathon Fry email = [email protected]
Next you need to update your
.gitconfig file to specify the root directory to apply your custom git config to e.g.
[includeIf "gitdir:~/Documents/Work/"] path = .gitconfig_work
This works by allowing you to apply a custom git config file to all subdirectories of the root directory provided.
You can specify as many
includeIf's as required e.g.
This technique is very flexible and can be applied as many times as needed allowing you to work on any number of projects whilst maintaining custom SSH/git configurations.
iamjonfry.com © 2018