The user.name
/user.email
has nothing to do with the account used to push to GitHub.
They only impact how the commit author is shown on GitHub
And that configuration can be set in each repository anyway, which means you don't have to change it when switching repos.
cd /path/to/repo1
git config user.name account1
git config user.email account2
The public key registered to a GitHub account is the one authenticating you.
Your ~/.ssh/config
file can reference the right key for the right repo, as described in "How to work on personal GitHub repo from office computer whose SSH key is already added to a work related GitHub account?"
You will need to change the remote repo URL accordingly:
cd /path/to/local/repo
git remote set-url origin github1:account1/repoA
With "github1
" being a Host
name section referencing the right public ssh key.