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.
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:
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
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.
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