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.
Step 1: Create SSH key
ssh-keygen -t rsa -C "firstname.lastname@example.org"
When asked for the name give a new file name:
Step 2: Create SSH config
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
Step 3: Register SSH keys
You need to register your new SSH keys
Step 1: Create a custom .gitconfig_work file
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@example.com
Step 2: Update your .gitconfig file
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.