Skip to content

Set up A Secondary Git Account

This blog explains how to set up a secondary git account for a project rather than using the global git configuration.

  1. Create a new SSH key pair for the secondary account
ssh-keygen -t ed25519 -C $EMAIL -f ~/.ssh/$PROJECT
vim ~/.ssh/config
  1. Add new SSH configuration into ~/.ssh/config
Host <Name>
    HostName github.com
    IdentityFile ~/.ssh/PROJECT
    IdentitiesOnly yes
    User git
  1. Setup Repo Git Configuration
git config user.email $EMAIL
git config user.name $NAME
git config user.signingkey $SIGNING_KEY
  1. Replace remote.
git remote set-url origin <Name>:<USERNAME>/<REPO>.git

For example, if you use as my-account, then the remote URL will be:

git remote set-url origin my-account:xieyuschen/xbot.git