Multiple git accounts

December 08, 2015

Let's suppose you have a personal git account and you don't want use it for professional purpose, how could you work with both handily?

So, you should have two ssh keys in your folder ~/.ssh. Assume id_rsa is your personal key and id_rsa_pro your professional key. We will change the ssh configuration in order to use your professional account.


# My professional account
Host github-pro
  User git
  IdentityFile ~/.ssh/id_rsa_pro

Hence, when cloning a repository, instead of using
git clone, you will clone this way:

git clone github-pro:MyCompany/Repository.git

If you have already cloned your project, you can change the remote:

git remote set-url origin github-pro:MyCompany/Repository.git

Finally, for each pro repository, you'll have to change locally your email and username:

cd /pro/repository
git config "ProName"
git config "ProEmail"


  1. Quick Tip: How to Work with GitHub and Multiple Accounts -
  2. Simplify Your Life With an SSH Config File -
  3. SSH/OpenSSH/Keys -
  4. Generating SSH keys -
  5. Changing a remote's URL -