Configuration files in GIT

GIT configuration can be stored at three locations local, global and system. GIT config tool handles all these configuration by setting and getting its values.


git config

It is tool used by GIT to set and get configuration variables, these configuration controls all aspects of how GIT looks and operates

GIT Local
These configurations are stored in the .git folder in the same location where the repository is created

.git\config                  //on Windows

.git/config                  //on Linux

GIT Global
These configuration resides in the home directory(C:\Users\<UserName>\) i.e %USERPROFILE% and the configuration is stored in the file .gitconfig

%USERPROFILE%\.gitconfig                       //on Windows
or
~/.gitconfig or ~/.config/git/config           //on linux

GIT System
These configuration resides at location C:\ProgramData\Git\config

C:\ProgramData\Git\config        //on Windows
or
/etc/gitconfig                   //on Linux

You can view all your settings and see where they are coming from using the below command

git config --list --show-origin

Precedence of configuration file from lowest of highest
1. System configuration (Lowest priority)
2. Global configuration
3. Local configuration (Highest priority)

If you want to see value of one of the settings then you can run the below command

git config user.name

Leave a Comment