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.
- Create a new SSH key pair for the secondary account
ssh-keygen -t ed25519 -C $EMAIL -f ~/.ssh/$PROJECT
vim ~/.ssh/config
- Add new SSH configuration into
~/.ssh/config
Host <Name>
HostName github.com
IdentityFile ~/.ssh/PROJECT
IdentitiesOnly yes
User git
- Setup Repo Git Configuration
git config user.email $EMAIL
git config user.name $NAME
git config user.signingkey $SIGNING_KEY
- 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