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 the need to be able to 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 get Git beginners to start pondering 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?

It should be stated that 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.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudApplications

SearchSoftwareQuality

SearchHRSoftware

SearchSAP

SearchERP

DevOpsAgenda

Close