Git on Windows: Whence Cometh Configuration

I recently went through the process of setting up a new development environment on Windows which included installing Git for Windows. At one point in the course of tweaking my environment, I found myself trying to determine which config file a particular setting originated. The command ‘git config –list’ showed the setting, but ‘git config –list –system’, ‘git config –list –global’, and ‘git config –list –local’ all failed to reflect the setting. Looking at the options for config, I discovered you can add a ‘–show-origin’ which led to a discovery: Git for Windows has an additional location from which it derives your configuration.

It turns out, since the last time I installed git on Windows, a change was made for the purposes of sharing git configuration across different git projects (namely, libgit2 and Git for Windows) where a Windows-specific location is now used as the lowest setting precedence (i.e. the default settings). This is the file: C:\ProgramData\Git\config. It doesn’t appear git added a way to list or edit this file as a well-known location (e.g. ‘git config –list windows’), so it’s not particularly discoverable aside from knowing about the ‘–show-origin’ switch.

So the order in which Git for Windows sources configuration information is as follows:

  1. C:\ProgramData\Git\config
  2. system config (e.g. C:\Program Files\Git\mingw64\etc\gitconfig)
  3. global config (%HOMEPATH%\.gitconfig
  4. local config (repository-specific .git/config)

Perhaps this article might help the next soul who finds themselves trying to figure out from where some seemingly magical git setting is originating.

About Derek Greer

Derek Greer is a consultant, aspiring software craftsman and agile enthusiast currently specializing in C# development on the .Net platform.
This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • Adam

    What does this level of configuration buy you that the combination of System, Global and Local doesn’t? As I understand it: System = every repo on the machine; Global = every repo a given user creates; Local = specific to a particular repository. Am I missing something obvious?

    • derekgreer

      The link to the change provides a more detailed description, but basically this change was made to enable different distributions of git to share common configuration. So, if you installed and Git for Windows then you could place common configuration there.

      • Adam

        Ah, if I’d followed the link I think I might have caught that. Cheers for clarifying! Now I’ve got to go research why on Earth I’d want to install different flavours of Git on my machine! :D

        • derekgreer

          This isn’t something most would probably use directly, but not knowing about this can be frustrating when you’re trying to track down where some default setting is coming from.