Managing Multiple Git(Hub) Profiles
A little Git(Hub) hack that I use to manage config for a couple of GitHub accounts (work plus personal if I’m doing a 10% or hackday thing)
Instead of changing one ~/.gitconfig
file, I have a simple one (plus also my generic aliases in there so they’re available for all profiles), with:
[includeIf "gitdir:~/home/"]
path = ~/home/.gitconfig
[includeIf "gitdir:~/work/"]
path = ~/work/.gitconfig
Then in the ~/work/.gitconfig
file I have:
email = work.email@example.com
name = Beth Anderson
[github]
user = "githubusername"
…and a different one in ~/home/.gitconfig
.
Then if I’m in the ~/work/...
directory it automatically uses my work user, and home for home…