Suppose I need to set a git alias that every user in the system has to use. Instead of asking each user to add this config to their $HOME/.gitconfig
, is it possible to declare this once globally for all users?
The docs say:
If not set explicitly with
--file
, there are four files wheregit config
will search for configuration options:
$GIT_DIR/config
Repository specific configuration file.
~/.gitconfig
User-specific configuration file. Also called "global" configuration file.
$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.
$(prefix)/etc/gitconfig
System-wide configuration file.
So:
/etc/gitconfig
is global~/.gitconfig
and $XDG_CONFIG_HOME/git/config
are per user$GIT_DIR/config
is per repoIn order to set a system wide option, do git config --add --system <OPTION>
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