Git configuration settings can be stored in three different files: The system configuration file, the global configuration file and the repository's local configuration file. See git on Windows - location of configuration files  for their locations.
When you use multiple subsystems on Windows (like MSYS2, Cygwin or any of the the Windows Subsystem for Linux distributions) it can be a chore to keep the git configurations synchronized. In other words: The less configuration files to maintain, the better.
Whether it's git for Windows, or one of the subsystem-specific git binaries:
Each of the git binaries that runs on Windows expands the tilde (
~) to the home directory, and the path separator is always a slash (
These features can be used in our advantage in order to simplify the git configuration files between all subsystems.
Re-defining the system
The system configuration file is meant to store all system-specific configuration settings, which will be applied to all users and git repositories on the system.
If you're the only user of your workstation, it makes sense to re-define system as subsystem:
All subsystem-dependent git configuration settings should be set in the system git configuration file.
This means that settings depending on underlying binaries, like tools to diff binary files (see Diff binary files like docx, odt and pdf with git ) or subsystem-specific files should be configured in the system git configuration file. Examples of such parameters are
http.sslcainfo http.sslbackend sendemail.smtpserver help.format diff.pdf.textconv
The system configuration has a fixed path, relative to the installation
. This configuration file can be read using
git config --list --system
Global means universal
Any user-specific setting should be set in the global git configuration file.
Let's suppose from Window's point of view, the home directory of MSYS2 is
, and that is where the master
file resides. By
symlinking that file from a command prompt from the Windows home directory
) one universal (or global) configuration file can be
used - only one that needs to be maintained. From the Windows shell:
mklink %USERPROFILE%\.gitconfig U:\.gitconfig
References to other user dependent files like global gitignore files can be set
using the tilde (
) notation and slash (
) path separator. They
need to be relative to the home directory.
git config --global --add core.excludesfile ~/.gitignore_global
Of course you still need to symlink the file
subsystem, similar to
. From Windows:
mklink %USERPROFILE%\.gitignore_global U:\.gitignore_global
The above workflow allows you to maintain a single personal git configuration file. For each new subsystem all you need to do is create the necessary symlinks, and everything is good to go. If you're using Debian on Windows for example, then the command will look something like:
mklink %USERPROFILE%\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\rootfs\home\%USERNAME%\.gitconfig U:\.gitconfig
The exact path depends on the Windows Subsystem for Linux distribution version, and your username.
So, if you're the only user of a system:
- subsystem-dependent settings go in the system configuration file, per subsystem.
- user-specific settings go in the global configuration file, per user.
- always use relative paths, using a tilde (
~) and slash (
|||(1, 2) https://www.onwebsecurity.com/configuration/git-on-windows-location-of-global-configuration-file.html|