Different .gitconfig for a given subdirectory?
I use two different git emails, one for work and one for public projects. Initially I thought that I could create a separate .gitconfig with a different email in a folder where all my public repos are in, and that git would respect that, but alas it seems that doesn't work. What's the best way to easily setup something similar? I want to avoid having to specifically change the email in each public repo.
I have the exact same problem. As a temporary solution, I have this in my .bashrc:
alias git='GIT_AUTHOR_EMAIL=$( p=$(pwd) while [[ $p != "$HOME" ]]; do [ -e $p/.gitemail ] && cat $p/.gitemail && break p=$(dirname $p) done) GIT_COMMITTER_EMAIL=$( p=$(pwd) while [[ $p != "$HOME" ]]; do [ -e $p/.gitemail ] && cat $p/.gitemail && break p=$(dirname $p) done) /usr/bin/git' alias g=git
This way I've got two different .gitemail files in the parent directories:
Note that I'm only switching user.email this way, everything else is centralized in ~/.gitconfig. It's a solution, but it's not great.
Hoping someone on StackOverflow has a better idea...