Essential Guide

Browse Sections

BACKGROUND IMAGE: deepagopi2011/

This content is part of the Essential Guide: Master Git basics and branch into DVCS
News Stay informed about the latest enterprise technology news and product updates.

Where system, global and local Windows Git config files are saved

One of the five basic Git commands beginners need to learn is git config, if for no other reason than they can perform a commit without the Git tool pestering them for a username and email address.

But the required git config command that sets up a username and email address typically employs a –global switch, which tends to have Git beginners start to ponder about alternate scopes and asking questions about where all of these Windows git configuration files are saved.

How to edit the global scoped Windows git config file.

Figure 1. Editing the global scoped Windows git config file.

System, global and local Git config files

Git provides three different scopes for storing configuration data. Accordingly, when using the git config command, one of these three scopes can be specified:

  1. Local
  2. Global
  3. System

The scopes are cascading, so system scope trumps global scope and local scope trumps global scope.

Names of Windows Git config files

Just to make life a bit more complicated, the Git configuration files all have different names. Furthermore, Windows Git config files are each stored in different locations.

  • The extensionless system Git config file is named gitconfig.
  • The global Git config file has no name, but is instead just an extension. The global Windows Git config file is named .gitconfig.
  • The local Windows Git configuration file is simply named config, and like the system Git config file, it has no extension.

Where are Git config files stored?

As for the location of these three Windows Git configuration files, here is where you’ll find them:

  • The system Git config file is found in the mingw32\etc folder of the Git installation.
  • The global Git configuration file is found in the root of the user’s local profile or home directory (C:\Users\git-user\).
  • The local Git config file is stored inside the .git directory of the repository in which you are working.

Can’t find the global git config file .gitconfig?

Sometimes users go looking for the global git config file, .gitconfig, and can’t find it. That’s because Git doesn’t actually create it until it’s used for the first time. Even just asking Git to edit the file will force its creation, but until that happens, efforts to find the .gitconfig file will be fruitless.

A quick command to force the creation of the .gitconfig file follows:

/c/ global/windows git config files (master)
$ git config --edit --global

Where Git stores system, global and local git config files.

Figure 2. The three locations of Windows Git configuration files.

Editing Windows Git config files

If you are interested in viewing or editing Git config files, simply use the git config command, specify the scope and add an –edit switch.

/c/ windows git config  (tutorial)
$ git config --global --edit
$ git config --system --edit
$ git config --local --edit

Each of these Git commands will open the corresponding Windows Git config file in the configuration specified editor. Just be careful, because if you incorrectly edit any of these files, you just might ruin your entire Windows Git config.

All of the source files for my DevOps examples and Git tutorials can be found on GitHub.

Further improve your DevOps tools knowledge

Mastered Git? The next step in your DevOps journey is mastering Jenkins CI. Here are some great Jenkins tutorials that will take you from beginner to expert.

Step 1 — How to download, configure and install Jenkins tutorial

Step 2 — Create your first Jenkins freestyle build job example

Step 3 — Pull from the Jenkins environment variables list in your shell scripts

Step 4 — Fix common Jenkins plugin installation errors

Step 5 — Add String and Boolean Jenkins parameters to your builds

Step 6 — Start pulling from GitHub with the Jenkins Git plugin

Step 7 — What happens when you git reset hard and push?

Step 8 — Get a handle on the  Jenkins vs. Maven debate

Step 9 — Learn how to do a hard git reset on a commit

Join the conversation


Send me notifications when other members comment.

Please create a username to comment.

Git's Portable Scope

Interestingly enough, I was informed that there is actually a fourth spot for configuration data on a Windows machine known is said to have 'portable Git scope.' 


Credit for this tip goes to Badr Elmers over at SO.

This is very interesting. Is there a way to specify portable scope using the "Git config [scope] --list --show-source" command? So far I only know of being able to set scope to:
FYI the dot in .gitconfig has nothing to do with file extensions, it is a carry over from UNIX style hidden files. In UNIX hidden files are denoted by beginning with a dot.

As a side-note file extensions aren't really a thing in UNIX systems like they are in Windows, file types tend to be derived by more reliable methods than the filename, such as a predictable sequence of bytes in a given file format).
That is to say, neither 'gitconfig' nor '.gitconfig' has a file extension; they are both extensionless txt files, one is simply intended to be hidden to avoid cluttering up the user's $HOME directory.
For a newbie like me, the order you explained about local, system, and global concepts are in different order in different sections which makes it hard to follow.

And have a table of columns (location, extension, cascade, ...) helps. 

Just a thought. Thanks for sharing.

Thanks for sharing.