I have a gitconfig
file that I share between machines since, for the most part, I want to use the same options on all of my machines. However, there are some things that are specific to the system (credential helper, difftool, etc.).
Is there any way to have a system specific part of the gitconfig
file (like I can in my bashrc
or vimrc
files)?
Yes, git has two user-specific configuration files: $XDG_CONFIG_HOME/git/config
and ~/.gitconfig
. The git-config man page explains $XDG_CONFIG_HOME/git/config
...
Second user-specific configuration file. If $XDG_CONFIG_HOME is not set or empty, $HOME/.config/git/config will be used. Any single-valued variable set in this file will be overwritten by whatever is in ~/.gitconfig. It is a good idea not to create this file if you sometimes use older versions of Git, as support for this file was added fairly recently.
So copy your generic config into $XDG_CONFIG_HOME/git/config
and put your system specific overrides into ~/.gitconfig
. If you don't have a XDG_CONFIG_HOME
environment variable, you should probably set it to $HOME
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With