Easy way to have 2 github profiles on my computer?

I have a personal account and a working github account, and I want to be able to push and pull depending on what I need.

Github won't let me use the same SSH key for both accounts, so how do I play this?

If I try to generate another SSH key, it will either overwrite the old one or not create a new one - should I just save it, say, in ~ / .ssh / id_rsa2?

And will I need to change the username and email address in my .gitconfig file every time I want to switch users, or can I specify multiple users there?

Simply put, what's the best (or any!) Way to manage multiple github accounts from the same machine?

+5
source share
2 answers

http://mherman.org/blog/2013/09/16/managing-multiple-github-accounts/

This blog post does a great job of detailing how to manage both accounts.

Basically, you will create an ssh configuration file and switch between them using ssh -T <profileName>

However, you need to save the keys in separate files.

+1
source

Another approach is to use the https url, which allows you to specify which account you want to use for a given remote repository:

 git remote set-url origin https://<username>@github.com/<username>/<reponame> 

With the netrc account assistant, you can save a password (or access token if you use 2fa ) for each account, which allows you to never enter them.
And you can also encrypt these passwords .

Remember to set the correct user.name and user.email for each local clone. Or you can control these settings using a script .

+1
source

Source: https://habr.com/ru/post/1211315/


All Articles