Nosotros have at present successfully learned most various Git Clients and a few mutual commands in the previous tutorials. Since we accept now Installed Git in our organization and learned nearly it, information technology is time for some applied on Git Bash . Nosotros will effort to make some changes to the configuration file of Git and set our credentials using Git Fustigate. I hope you think, we volition be using Git Bash merely for this course. In this tutorial, nosotros will

  • Gear up Default Credentials for Git Config
  • View list of User's Settings of Git Config

Before going on to these sections, we should start empathize why nosotros need to make changes to our configuration file as we install Git or start using it for the offset time.

Why set Configuration File in Git?

As nosotros install Git in our system, the configuration file takes default values for some of the fields. This means Git starts by setting the aforementioned files for every user. Although many of these values are default and are kept that way, merely the personal ones should non. This creates a conflict in the identity of the programmer among the squad about which we volition run across through an case in this section. So when y'all first starting time Git, the mutual default files (that are common to every user) are searched inside the /etc/gitconfig file of the Git. Once these are set, Git has to encounter the files specific to a particular user. These specific files are bachelor nether ~/.gitconfig or ~/.config/git/config file. The specific file includes your username, your name, etc.

Visit your Git Bash and type the following command to come across the personal Configuration Settings .

vi ~/.gitconfig

 git_config_directory

Don't worry well-nigh the Half dozen editor. We will discuss it while we ready our text editor. Press enter and see your configuration file. Mine is already set to testify you. Y'all will not get whatever value if y'all accept not already set it.

Let see an example to see why we need to set up these values while working on a projection. Many people work on one project but the only affair that can identify you lot is your username or e-mail. If you don't configure these values within your config file, these values (name and electronic mail, etc) are taken randomly. Then when you commit any change, this modify is reflected along with your username and email which are random and no ane will be able to recognize or recollect your credentials. This creates a lot of problems in the squad. Hence, we should alter this config file.

How to Prepare Default Credentials for Git Config?

Gear up user's UserName in Git Config

The first alter that nosotros will exist making inside our config file will exist changing our username in Git. To change our username, follow these steps.

Open Git Bash in your organisation. Type the post-obit command with your username :

git config --global user.name "Your UserName"

global_user_name

Notation : Since I entered my own username above, that displays Rajora, Harish. Also changing your username will only impact your future commits and none of your by commits.

This will change the user name to the value yous gave in the command. Press enter and if nothing happened, the name was changed successfully.

Y'all might get some fault which would exist self-explained by Git. For example if you forget to put the " . " in between user and name, yous might become an error similar this

global_user_name_error

Set user's Email in Git Config

Afterward executing the higher up control successfully, we will change our electronic mail. Blazon the post-obit command

git config --global user.email "Your EmailID"

git_global_email_set

It volition change the email id in the Git Config to the email id you mentioned in the command.

Note : It is very of import to annotation that we use --global for personal config files while we use --system to make changes to the default file discussed in the above section. This file should be retained as it is.

How to view a list of User's Settings of Git Config?

Once yous have set up all the values in the configuration file, yous tin view all the settings also through Git Bash.

View the complete listing of setting in Git Config

For that go to Git Bash and type this command.

git config --listing

git_config_list

Press enter and you lot tin can see all the settings including the ones that nosotros just set up in the above department.

git_config_list

View a particular setting in Git Config

You can as well check for a particular setting in the configuration file instead of opening the consummate list. To see this follow these unproblematic steps.

In the Git Fustigate type the following command:

git config --global <key>

git_config_key

<key> hither refers to the name of the setting that y'all want to see. For the case in a higher place the key is user.proper name that we set up in the above sections. You need to call up the key-value exactly as information technology is. In this example, it is non a username but user.name. If you lot cannot recollect, you can always brandish the complete list of config files.

Printing enter to see the key-value

 git_config_key_value

I hither strongly recommend visiting Git Config folio near git --config and get your easily dirty on it after reading this tutorial.