Useful systemwide git defaults -- revisited
A while back, I wrote about
“useful git defaults”. This is a tricky subject, as a sufficiently aged
~/.gitconfig is much like a
vimrc or Chief O’Brien’s rank: a very
Nonetheless, it’s one of those things where a few small adjustments to
the system-wide git configuration (a la
/etc/gitconfig) can make things
much, much easier — particularly in the case where there are multiple systems
to manage, and multiple people using them.
I’m pretty happy with those defaults, but a lot has changed since 2014.
git config file locations
The configuration paths available have also changed:
To do this, we can leverage the little-used system-wide git config file at
/etc/gitconfig. Remember that by default git looks at four files to
determine its configuration (in ascending order of priority):
~/.gitconfig(user aka global), and
.git/config(configuration for the current repository).
(Technically, #2 is
This allows us to set defaults in the system configuration file without
interfering with people who prefer different settings: their global config at
~/.gitconfig will win.
For our purposes, we’re talking about settings in
they can certainly be used in other places as well.
This config sets a couple safer defaults for pushing, makes git merge/diff/rebase a little more DWIM, causes the committer, as well as the author, information to be displayed by default, as well as allowing for an easy way to override the system config on a per-system basis. (In case, say, you’re using puppet or the like to distribute this configuration across multiple hosts.)
Note that we do not do some things that individuals may wish to do, as we’re
aiming for “unobtrusive, reasonable universal defaults”, e.g.
rebase.autosquash is not set to
true. (Though the author highly
recommends this setting.)