How to see git configuration - Walking Techie

Blog about Java programming, Design Pattern, and Data Structure.

Saturday, July 25, 2020

How to see git configuration

In the last post, we have seen how to install Git into Ubuntu machine and some configuration of it. In this post we will see more about config.

How to get username and email

We have set the user name and email in the last post. How can we get the username and email to verify it?

   $ git config --get user.name

This will return the username. Username can be picked up from local config if you are in repository otherwise it will pick from global configuration.

   $ git config --get user.email

This will return the email of user. Email can be picked up from local config if you are in repository otherwise it will pick from global configuration.

You can fetch user name and email from specific configuration by passing the options. You can do like below.

To get from global configuration file. Need to pass --global.

   $ git config --global --get user.name
   $ git config --global --get user.email

To get from local configuration file. Need to pass --local. To run the below command, you must be in local repository.

   $ git config --local --get user.name
   $ git config --local --get user.email

List Git Settings

You can print the Git setting using the below command.

   $ git config --list

You are in local repository and run this command. It will list all the local, global and system config. But if you are not in git directory then it will list system and global config of git.

List Git Settings by config

To print the system config. pass the --system option.

   $ git config --system --list

To print the global user config. pass the --global option.

   $ git config --global --list

To print the local user config. pass the --local option. You must be in git repo.

   $ git config --local --list

No comments :

Post a Comment