Home

Misc

2022 June 11

Multiple Git Users

To use ultiple github accounts follow these steps:

1 - Use github ssh for the secondary key: - `ssh-keygen` inside your ~/.ssh folder, give it a different name like `_SECONDAC` - copy the contents of the public key (.pub) - add it to github settings for ssh keys - add an entry to ~/.ssh/config for your second account (i included main acct for comparison): Host github.com IdentityFile ~/.ssh/key_FIRSTACC HostName github.com User FIRSTACC Host github.com-SECONDACC IdentityFile ~/.ssh/key_SECONDACC HostName github.com User SECONDACC

2 - inside the repository folder switch to the new user:

git config user.email SECONDACC@x.com git config user.name SECONDACC

3 - use the long form ssh command to push:

git push ssh://git@github.com-SECONDACC/SECONDACC/REPONAME master:master

(optionally) - I think you can github ssh remote inside the repository,

git remote add sshremote git@github.com:SECONDACC/REPONAME

Signup For More