-
-
Save hillbilly300/303457b2736e022945439966c3717150 to your computer and use it in GitHub Desktop.
Multiple git accounts accounts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#In your ~/.gitconfig you can put something like this. | |
# git version > 2.13 | |
# https://stackoverflow.com/questions/8801729/is-it-possible-to-have-different-git-config-for-different-projects/43884702#43884702 | |
[includeIf "gitdir:~/company_a/"] | |
path = .gitconfig-company_a | |
[includeIf "gitdir:~/company_b/"] | |
path = .gitconfig-company_b | |
#Example contents of .gitconfig-company_a | |
[user] | |
name = Pradeep singh | |
email = [email protected] | |
#Example contents of .gitconfig-company_b | |
[user] | |
name = Pradeep Singh | |
email = [email protected] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create two rsa keys with different name. add corresponding key in git accounts (.pub files) | |
# in ~/.ssh/config | |
# ref - https://medium.freecodecamp.org/manage-multiple-github-accounts-the-ssh-way-2dadc30ccaca | |
# Personal account, - the default config | |
Host github.com | |
HostName github.com | |
User git | |
IdentityFile ~/.ssh/id_rsa | |
# Work account-1 | |
Host github.com-work_user1 | |
HostName github.com | |
User git | |
IdentityFile ~/.ssh/id_rsa_work_user1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment