2.5. Mulitple Accounts - shinokada/gitnotes GitHub Wiki
Quick Tip: How to Work with GitHub and Multiple Accounts
ssh-keygen -t rsa -C "my-email-address"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/myname/.ssh/id_rsa): /Users/myname/.ssh/id_rsa_sokada
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/teacher/.ssh/id_rsa_sokada.
Your public key has been saved in /Users/teacher/.ssh/id_rsa_sokada.pub.
The key fingerprint is:
Copy the content of ~/.ssh/id_rsa_newname to GitHub SSH Public Keys. And run the following to add ssh.
ssh-add ~/.ssh/id_rsa_sokada
# output
Enter passphrase for /Users/myname/.ssh/id_rsa_sokada:
Identity added: /Users/myname/.ssh/id_rsa_sokada (/Users/myname/.ssh/id_rsa_sokada)
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
Host github-sokada
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_sokada
# if you have fatal: remote origin already exists.
git remote rm origin
# add origin
git remote add origin git@github-sokada:shinokadagist/Grade6
git push -u origin master
# check your git config list
git config --list
Now you can git push normally.git push origin master
.
After clone a wiki, you may get an error message.
remote: Permission to shinokadagist/Grade6.wiki.git denied to shinokada.
fatal: unable to access 'https://github.com/shinokadagist/Grade6.wiki.git/': The requested URL returned error: 403
git remote rm origin
git remote add origin git@github-sokada:shinokadagist/Grade6.wiki.git
# Then commit and push
# open a local git config
git config -e # --edit
# delete all cached keys
ssh-add -D
# check saved keys
ssh-add -l # --list