Gitprogramming languages

how to use Git Config, explained with practical implementation

Git Config, Description:

How To use git config–  in this article, I am going to show you the basic git setting and how you can use the git config command to edit the setting.

Git Setup:

In my previous Git article, I explained the full process of downloading and installing the git. So, read my previous article, when you have installed Git on your machine, you need to set up its environment. On each computer, this procedure is performed only once; when updating, all settings are saved. However, you can change them again at any time by using the specified commands.

The Git system comes with the git config tool, which allows you to get and set configuration variables that control all aspects of how Git looks and works. These variables are stored in different places.

  • The /etc/gitconfig file contains values ​​that apply to all system users and all their repositories. Specifying the –system option when running git config will achieve read and write access for that particular file.
  • The file ~/.gitconfig or ~/.config/git/config is associated with a particular user. Reading and writing to this file is initiated by passing the –global option.
  • The configuration file settings in the Git folder (i.e. .git/config) of the repository you are currently working will affect only that specific repository.

The settings of each next level, override the settings of the previous one, that is, the configuration from .git/config will override the configuration from /etc/gitconfig.

On Windows systems, Git looks for the .gitconfig file in the $HOME folder (in most cases it’s nested in the C:\Users\$USER folder). In addition, the /etc/gitconfig file is looked for, but this time relative to the MSys root directory, the location of which you yourself choose when installing Git.

Git ID:

When installing Git, the first step is to provide a username and email address. This is important because this information will be included by Git in every version you commit, and it is required to be included in all commits (committed data) you create:

git config

git config

Passing the –global option allows you to make these settings only once, because in this case, Git will use this information for all your actions in the system. If a specific project requires a different name or email address, go to the project folder and run this command without the –global option.

Many GUI tools help you perform these steps the first time you run them.

Git Editor:

Now, that you’ve entered your personal information, it’s time to select the text editor that will be used by default when you need to print a message in Git. Without this setting, Git will use the operating system’s default editor, usually Vim. If you prefer another text editor such as Emacs, do the following:

git config

Git Settings checking:

You can check the selected settings using the git config –list command, which displays a list of all currently detected settings:

git config

Some keys may appear more than once because Git reads the same key from different files (eg /etc/gitconfig and ~/.gitconfig). In this case, the system uses the latest value for each unique key it discovers.

You can also check the value of a particular key using the git config <key> command:

git config

git Help commands:

There are many ways to access the help page for any Git command:

git config

git config

git config

git config

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button