Coffee Talk: Java, News, Stories and Opinions

May 30 2018   7:24PM GMT

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

cameronmcnz Cameron McKenzie Profile: cameronmcnz


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

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: