Skip to content

Instantly share code, notes, and snippets.

@ndkhoa
Last active December 24, 2020 05:37
Show Gist options
  • Select an option

  • Save ndkhoa/d8994f59d4c6f4d525a0a9b80056550a to your computer and use it in GitHub Desktop.

Select an option

Save ndkhoa/d8994f59d4c6f4d525a0a9b80056550a to your computer and use it in GitHub Desktop.
Multiple Github Accounts
================================================================================
================================================================================
mkdir ~/git-acc
touch ~/git-acc/khoachilang.sh
touch ~/git-acc/fooderio.sh
========================================
========================================
~/git-acc/khoachilang.sh
#!/bin/bash
cp ~/.ssh/khoachilang/khoachilang ~/.ssh/id_rsa
cp ~/.ssh/khoachilang/khoachilang.pub ~/.ssh/id_rsa.pub
git config --global user.name "Khoa Nguyen"
git config --global user.email [email protected]
eval "$(ssh-agent -s)"
ssh -T [email protected]
git config user.name
git config user.email
========================================
========================================
~/git-acc/fooderio.sh
#!/bin/bash
cp ~/.ssh/fooderio/fooderio ~/.ssh/id_rsa
cp ~/.ssh/fooderio/fooderio.pub ~/.ssh/id_rsa.pub
git config --global user.name "Khoa Nguyen"
git config --global user.email [email protected]
eval "$(ssh-agent -s)"
ssh -T [email protected]
git config user.name
git config user.email
========================================
========================================
~/.zshrc
...
# Github Accounts
alias khoachilang="~/git-acc/khoachilang.sh"
alias fooderio="~/git-acc/fooderio.sh"
========================================
========================================
source ~/.zshrc
khoachilang
fooderio
================================================================================
================================================================================
https://gist.github.com/Jonalogy/54091c98946cfe4f8cdab2bea79430f9
Handling Multiple Github Accounts on MacOS
================================================================================
================================================================================
https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/testing-your-ssh-connection
========================================
========================================
ssh-keygen -t rsa -b 4096 -C "[email protected]"
fooderio
================================================================================
================================================================================
https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup
================================================================================
================================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment