Skip to content

Instantly share code, notes, and snippets.

@obar1
Created November 4, 2022 18:37
Show Gist options
  • Select an option

  • Save obar1/2902c847aede24e9fc8008063e9b70f7 to your computer and use it in GitHub Desktop.

Select an option

Save obar1/2902c847aede24e9fc8008063e9b70f7 to your computer and use it in GitHub Desktop.
multiple github account

Relevant steps from the first link:

ref

https://code.tutsplus.com/tutorials/quick-tip-how-to-work-with-github-and-multiple-accounts--net-22574

Generate an SSH-key:

ssh-keygen -t ed25519 -C "[email protected]"
Follow the prompts and decide a name, e.g. id_ed25519_example_company.

Copy the SSH public-key to GitHub from ~/.ssh/id_ed25519_doe_company.pub and tell ssh about the key:

ssh-add ~/.ssh/id_ed25519_doe_company
Create a config file in ~/.ssh with the following contents:

Host github-doe-company
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_doe_company
Add your remote:

git remote add origin git@github-doe-company:username/repo.git
or change using:

git remote set-url origin git@github-doe-company:username/repo.git

upload

https://github.com/settings/keys

edit config

Host github-gf
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_gf

Host github-obar1
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_obar1

use it

git clone git@github-gf:work/random.git


git clone git@github-obar1:obar1/random.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment