Skip to content

Instantly share code, notes, and snippets.

@DorinMol
Last active June 9, 2023 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DorinMol/f9438f63bfdf9f9f09e42c6e25af165c to your computer and use it in GitHub Desktop.
Save DorinMol/f9438f63bfdf9f9f09e42c6e25af165c to your computer and use it in GitHub Desktop.
Git/Github - multiple accounts
1. Generate 2 or more gpg keys https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key
2. Those keys will be under ~/.ssh
3. Add them to the right accounts
4. Edit config file under ~/.ssh
cat ~/.ssh/config
Host personal
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_personal
# UseKeychain yes
Host work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
# UseKeychain yes
5. Check GPG keys needed for next step: gpg --list-secret-keys --keyid-format=long
6. Add user details globally
git config --global user.name "Mona Lisa"
git config --global user.email "Mona@Lisa.com"
git config --global user.signingkey "KeyID" -> this key can be found from step 5 (rsa4096/<key_id> 2022-12-21 [SC])
7. Now to add specific project keys ( local ), cd into project folder and run the below
git config --local user.name "Mona Lisa"
git config --local user.email "Mona@Lisa.com"
git config --local user.signingkey "KeyID" -> this key can be found from step 5 (rsa4096/<key_id> 2022-12-21 [SC])
git remote add <NAME> "personal:<path>"
That should be it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment