Skip to content

Instantly share code, notes, and snippets.

Avatar

Eliton D. Gadotti 1eliton

View GitHub Profile
@Jonalogy
Jonalogy / handling_multiple_github_accounts.md
Last active March 31, 2023 01:00
Handling Multiple Github Accounts on MacOS
View handling_multiple_github_accounts.md

Handling Multiple Github Accounts on MacOS

The only way I've succeeded so far is to employ SSH.

Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:

Host *
 AddKeysToAgent yes

> UseKeyChain yes

@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active March 31, 2023 08:40
Using multiple github accounts with ssh keys
View using-multiple-github-accounts-with-ssh-keys.md

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.