If you see it

Live for passion

Github Multiple Accounts Usage Notes

Scenario
When you have a local repo and a new github repo, if you want to push to the new repo with one of your github account credential.

Check the config under .ssh.

~/.ssh/config
1
2
3
4
5
6
7
8
Host github-tw
          HostName github.com
          IdentityFile ~/.ssh/id_rsa
          User git
  Host github-lynnequ
          HostName github.com
          IdentityFile ~/.ssh/id_rsa_lynnequ
          User git

Instead of adding your remote origin like this:

1
git remote add origin git@github.com:GITHUB_USERNAME/REPO_NAME.git

You should according change your host to which one exist and you are willing to use in config file

1
git remote add origin git@github-lynnequ:GITHUB_USERNAME/REPO_NAME

Comments