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
- Add new SSH configuration into
~/.ssh/config
- Setup Repo Git Configuration
git config user.email $EMAIL
git config user.name $NAME
SIGNING_KEY="$(gpg --list-secret-keys --with-colons "$EMAIL" | awk -F: '$1 == "fpr" { print $10; exit }')"
if [ -z "$SIGNING_KEY" ]; then
echo "No local GPG secret key found for $EMAIL"
exit 1
fi
git config user.signingkey "$SIGNING_KEY"
- Replace remote.
For example, if you use my-account, then the remote URL will be: