Skip to content

Committing as a Different User

Posted on:June 18, 2021

First create a new SSH key pair to use with your alternate account.

ssh-keygen -t rsa

Add the public key to your alternate account on Github (Settings > SSH and GPG keys).

Once that’s done, add a new entry in your SSH config, usually located in ~/.ssh/config:

   User git
   IdentityFile ~/.ssh/something is a unique placeholder that SSH will use to resolve the settings to use (in this case, which actual host to connect to, using which private key) — it can be anything you like. Point IdentityFile to the location of the private key of the SSH key pair.

In the .git folder of the project you want to commit to using your alternate account, put the following settings in .git/config:

        name = My Alternate Account
        email =
[remote "origin"]
        url =
        fetch = +refs/heads/*:refs/remotes/origin/*

Make sure the same in the SSH config entry is used as the host in the url field. Tweak the rest of the settings to your liking.

That’s it!