Conditional Includes
Aug 30, 2018
Quick tip: Use Git’s conditional includes to manage multiple Github user accounts.
The data that follows the gitdir
keyword is used as a global pattern and if the location of the .git directory matches the pattern, the include condition is met. This enables specified directories to be configured for certain accounts.
# ~/.gitconfig
[user]
name = John Doe
email = john.doe@account1.com
[includeIf "gitdir:~/xyz/"]
path = ~/xyz/.gitconfig# ~/xyz/.gitconfig
[user]
email = john.doe@account2.com