It turns out that you can include files in your
~/.gitconfig. One thing
the docs don’t explain is that missing files are silently ignored.
In addition you can include files conditionally based on where the git
repo is and what the branch name is.
All these make things much easier for my home dir to work across environments.
For example I have a
crypt repo which includes encrypted versions of
my gpg keys. I only check it out on machines I keep secure (encrypted
hard drives, not portable, etc) so I don’t always have gpg keys available.
When I do have the keys though, I’d like to always sign commits.
The solution is to do this in my
If the file exists it will set up autosigning, if not, nothing happens. There’s no error. Perfect!
I also write code for myself, for my employer and for some clients.
I set my email in the
[user] block, but I can override it for
And then in
~/.gitconfig.d/client1 I have this:
I’m not quite sure how else this will be useful, but this alone should stop me committing with the wrong address which is a win in itself. Back when reviewboard was a thing it might be useful there too, but hopefully that’s in the past.