Git is used as distributed version control system for the majority of projects I work on. On Windows I use the official Git for Windows version, as well as the 'native' mingw/MSYS2 git binary when using the MSYS2 shell.

The location of the system and global gitconfig configuration files varies depending on which environment (native Windows command, Windows shell or MSYS2 shell) you're using, and depending on which binary (Git for Windows versus native git).

Git version 2 introduced a much easier method of finding where the git configuration is stored, the --show-origin flag. This parameter tells you exactly where the configuration files can be found.

Retrieve the locations (and name value pairs) of all git configuration files:

git config --list --show-origin

Retrieve the location (and name value pairs) of the system git configuration file:

git config --list --system --show-origin

Retrieve the locations of all git configuration files:

git config --list --show-origin | awk '{print $1}' | uniq


Regardless from where you use git on Windows, the repository (local) configuration always resides at the same location, in the root directory of your repository: .git\config

You can check this configuration using

git config --list --local


The system configuration has also a fixed path on Windows, relative to the installation directory: etc\gitconfig

  • For msysGit: %ProgramFiles(x86)%\Git\etc\gitconfig
  • For Git for Windows (64 bit): %ProgramFiles%\Git\mingw64\etc\gitconfig
  • For git under MSYS2: [MSYS2-install-path]\etc\gitconfig

This configuration file can be read using

git config --list --system


This is the tricky one. When using the Windows command shell, batch scripts or Windows programs, the file will be read from %USERPROFILE%\.gitconfig

However, when you're using msys (bash) this will be read from $HOME/.gitconfig

Yet another different location can be found from within Emacs (for instance by using magit) when Emacs is started from a Windows command shell. Emacs sets the HOME variable as %APPDATA% , which means that .gitconfig will reside in %APPDATA%\.gitconfig

This configuration file can be read using

git config --list --global

Workflow setup: Linking the global configuration

In my workflow I symlink the various versions of the global configuration. The system configration stays independent. The file at %USERPROFILE%\.gitconfig is considered the master global file where you make all your changes.

Run this command from within a Windows command shell to create a symbolic link for the system and global file. Be careful, as this command deletes the current gitconfig file in your MSYS2 home directory, as well as the one in %APPDATA% . Moreover mklink doesn't expand variables, so you'll have to type in the expanded path yourself.

mklink /h %APPDATA%\.gitconfig %USERPROFILE%\.gitconfig
mklink /h [MSYS2-install-path]\home\[username]\.gitconfig


  • 2017-10-19: Formatting
  • 2017-09-17: Formatting
  • 2016-12-03: Added new --show-location option, changed git binary, edits.


comments powered by Disqus