Multiple Accounts and Git

If you have multiple accounts that you must use with Git — such as a personal and a work account — you can have your Git Config (typically ~/.gitconfig) conditionally include other configs depending on the folder you’re working in. In those extra configs you then can override some settings. Here’s an example ~/.gitconfig that …


This content originally appeared on Bram.us and was authored by Bramus!

If you have multiple accounts that you must use with Git — such as a personal and a work account — you can have your Git Config (typically ~/.gitconfig) conditionally include other configs depending on the folder you’re working in. In those extra configs you then can override some settings.

Here’s an example ~/.gitconfig that has two dynamic includes:

[user]
  name = "John Doe"

[includeIf "gitdir:~/repos/personal/"]
  path = ~/.gitconfig.personal

[includeIf "gitdir:~/repos/work/"]
  path = ~/.gitconfig.work

Inside each ~/.gitconfig.XXX you can then list extra config values, here the email address to use for each:

[user]
  email = john@example.org

? If you want to use individual SSH keys for each account, there’s some more steps you need to take.


This content originally appeared on Bram.us and was authored by Bramus!


Print Share Comment Cite Upload Translate Updates
APA

Bramus! | Sciencx (2021-09-02T22:30:37+00:00) Multiple Accounts and Git. Retrieved from https://www.scien.cx/2021/09/02/multiple-accounts-and-git/

MLA
" » Multiple Accounts and Git." Bramus! | Sciencx - Thursday September 2, 2021, https://www.scien.cx/2021/09/02/multiple-accounts-and-git/
HARVARD
Bramus! | Sciencx Thursday September 2, 2021 » Multiple Accounts and Git., viewed ,<https://www.scien.cx/2021/09/02/multiple-accounts-and-git/>
VANCOUVER
Bramus! | Sciencx - » Multiple Accounts and Git. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/02/multiple-accounts-and-git/
CHICAGO
" » Multiple Accounts and Git." Bramus! | Sciencx - Accessed . https://www.scien.cx/2021/09/02/multiple-accounts-and-git/
IEEE
" » Multiple Accounts and Git." Bramus! | Sciencx [Online]. Available: https://www.scien.cx/2021/09/02/multiple-accounts-and-git/. [Accessed: ]
rf:citation
» Multiple Accounts and Git | Bramus! | Sciencx | https://www.scien.cx/2021/09/02/multiple-accounts-and-git/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.