I have some git repositories on my local machine that are hobby projects (hosted on GitHub), and some that are work-related (hosted elsewhere). Because I am doing it wrong (don't ask, it's irrelevant) I periodically have to rm -rf
and re-clone a repo, which also wipes out its .git/config
file.
I would like to put something in my ~/.gitconfig
that would set user.email
differently for my work projects than my hobby projects. (Remember, I can't use .git/config
because it periodically gets wiped out.) This could be based on the project name, or based on the URL of the remote repo I'm cloning.
As a separate but related issue, I would love to be able to specify a global pre-commit hook that applied to all my repositories, rather than having to remember to modify .git/hooks/pre-commit
every time I clone a repo. (I am aware of git clone --template
.)
I suppose I could write a Bash script aliased to git
that would do all this setup whenever it noticed me doing a git clone
. Is that the only answer, then?