In my ~/.gitconfig, I list my personal email address under [user], since that\'s what I want to use for Github repos.
But, I\'ve recently s
Maybe it is a simple hack, but it is useful. Just generate 2 ssh keys like below.
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/GowthamSai/.ssh/id_rsa): work
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in damsn.
Your public key has been saved in damsn.pub.
The key fingerprint is:
SHA256:CrsKDJWVVek5GTCqmq8/8RnwvAo1G6UOmQFbzddcoAY GowthamSai@Gowtham-MacBook-Air.local
The key's randomart image is:
+---[RSA 4096]----+
|. .oEo+=o+. |
|.o o+o.o= |
|o o o.o. + |
| =.+ . = |
|= *+. S. |
|o*.++o . |
|=.oo.+. |
| +. +. |
|.o=+. |
+----[SHA256]-----+
Same way create one more for personal. So, you have 2 ssh keys, work and company. Copy work.pub, work, personal.pub, personal to ~/.ssh/ Directory.
Then create a shell script with the following lines and name it as crev.sh (Company Reverse) with the following content.
cp ~/.ssh/work ~/.ssh/id_rsa
cp ~/.ssh/work.pub ~/.ssh/id_rsa.pub
Same way, create one more called prev.sh (Personal Reverse) with the following content.
cp ~/.ssh/personal ~/.ssh/id_rsa
cp ~/.ssh/personal.pub ~/.ssh/id_rsa.pub
in ~/.bashrc add aliases for those scripts like below
alias crev="sh ~/.ssh/crev.sh"
alias prev="sh ~/.ssh/prev.sh"
source ~/.bashrc
Whenever you wanna use company, just do crev, and if you wanna use personal do prev :-p.
Add those ssh keys to your GitHub accounts. Make sure, you don't have id_rsa generated previously, because those scripts will overwrite id_rsa. If you have already generated id_rsa, use that for one of the accounts. Copy them as personal and skip the generation of personal keys.