How to View Git Configuration

Abdul Jabbar Feb 02, 2024
  1. System Git Config Files
  2. View Git Config
  3. Using the git config Command
  4. Using the git config --list Command
  5. Looking in the Git Configuration File
How to View Git Configuration

Git is a well-known and commonly used version control system globally.

When working with Git, developers have access to their repositories locally, through which many developers can work under the same project in a vast team.

Thus, every team member has a different way of working. That is why every team member can have different local Git configurations.

Initially, when we start working with this version control system, we need to do some setup, which is only done once. For this situation, Git has a tool called git config, which means you can customize the Git environment according to personal preferences.

This tool will help us set configuration options to control the entire Git installation, that is, how it will look and work to pull or push the data to the repositories. This tool will help organize our email editors and often allows us to deal with aliases for the git command to use in the future.

This article will demonstrate how to view the configurations in Git using the git config command. We will look at the different git config commands that we need to start.

Let’s explore different types of Git configurations in the following.

System Git Config Files

Git comes up with four standard possibilities to store data. The fifth one is a portable scope available on the Windows operating system.

The below-mentioned list is in descending order according to their specificity:

  1. Worktree
  2. Local
  3. Global
  4. System
  5. Portable

View Git Config

The three ways to view Git configuration are as follows. We will explore these commands one by one with examples.

  1. The git config command
  2. The git config --list command
  3. Looking in our Git configuration file

Using the git config Command

The git config command is the most straightforward function that we will use to set Git configuration, whether on a global or a local project.

Below is the git config command that shows the username of the user working on a Git environment:

git config user.name

In this case, it gives the output the name of the user:

John

Using the git config --list Command

The git config --list command will result in entire Git configuration properties mainly used in scoped Git files.

This git config command can proceed as follows:

git config --list

This command provides the result with all the relevant information related to the name, email, and tool-specific details saved in the configurations file:

user.name=John
user.email= John@gmail.com
merge.tool=vimdiff

Looking in the Git Configuration File

We can also view our Username in the git configuration file through the HOME directory on Unix systems as follows:

~/.gitconfig

The file on a current test system is viewed as follows:

[user]
        name = Peter Johnson
        email = [omitted]
[merge]
        tool = vimdiff

This is our global Git username. We can also use a different username as per the project in the local environment according to our preferences.

Author: Abdul Jabbar
Abdul Jabbar avatar Abdul Jabbar avatar

Abdul is a software engineer with an architect background and a passion for full-stack web development with eight years of professional experience in analysis, design, development, implementation, performance tuning, and implementation of business applications.

LinkedIn

Related Article - Git Config