Where Is the Global Git Config Data Stored?

Better Stack Team
Updated on August 12, 2024

The global Git configuration data is stored in a file located in your home directory. The specific location and file name may vary depending on your operating system:

Location of Global Git Config File

  • Unix-based Systems (Linux, macOS): The global Git configuration file is located at:

     
    ~/.gitconfig
    

    Here, ~ represents your home directory.

  • Windows: The global Git configuration file is located at:

     
    C:\\Users\\<YourUsername>\\.gitconfig
    

    Replace <YourUsername> with your actual Windows user account name.

Viewing and Editing the Global Git Config

To view the global Git configuration, you can use the git config command:

 
git config --global --list

This command lists all the global settings currently configured in your .gitconfig file.

To edit the global Git configuration file directly, you can open the .gitconfig file in your favorite text editor. For example:

  • Unix-based Systems:

     
    nano ~/.gitconfig
    

    or

     
    vim ~/.gitconfig
    
  • Windows:

    Open Notepad or any text editor and navigate to C:\\Users\\<YourUsername>\\.gitconfig.

Structure of the .gitconfig File

The .gitconfig file is typically formatted in .ini style with sections and key-value pairs. Here’s an example of what it might look like:

 
[user]
    name = Your Name
    email = your.email@example.com
[core]
    editor = vim
[alias]
    st = status
    co = checkout
  • Sections: Enclosed in square brackets (e.g., [user]).
  • Keys and Values: Each key-value pair is specified as key = value.

Changing Global Configuration

To change global Git configuration settings, you use the git config command with the --global flag. For example:

  • Set a global user name:

     
    git config --global user.name "Your Name"
    
  • Set a global user email:

     
    git config --global user.email "your.email@example.com"
    

Summary

The global Git configuration data is stored in a file named .gitconfig:

  • On Unix-based Systems: Located at ~/.gitconfig
  • On Windows: Located at C:\\Users\\<YourUsername>\\.gitconfig

You can view and edit this file to manage global Git settings or use git config commands to update the configuration.

Got an article suggestion? Let us know
Explore more
Git
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.