Site icon i2tutorials

Git – Configuration

Git Configuration 

 

A Git configuration defines the settings and preferences that determine how the Git version control system behaves. There are three configuration files: a system-wide file, a user-specific file, and a repository-specific file. Git configuration files allow users to customize Git’s behavior, including choosing the default text editor, specifying the user’s name and e-mail, and configuring other Git-related tools and settings.

Git config levels and files :

We’ll take a moment to cover configuration levels before discussing git config. The git config command can accept arguments to specify the configuration level to operate on.

–local

If no configuration option is passed, git config will write at a local level by default. .git/config stores local configuration values in a file that can be found in the .git directory of the repo: .git/config. Local configuration values are applied to the context repository where git config gets invoked

 –global

~/.gitconfig on Unix/Linux systems and C:/Users//.gitconfig on Windows. Global configuration values are stored in a file in a user’s home directory

 –system

An entire machine is configured at a system level. It covers all users and repositories on an operating system. The gitconfig file is located in $(prefix)/etc/gitconfig on unix systems. If you are using Windows XP, you will find this file in C:/Documents and Settings/All Users/Application Data/Git/config, while if you are using Windows Vista or newer, you will find it in C:/ProgramData/Git/config.

There are three configuration levels: local, global, and system.When looking for a configuration value, Git starts at the local level and bubbles up. 

Writing a value :

Let’s take a look at an example of how we might write a value in git config:

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

Using the –global flag, this example sets the value your_email@example.com to the configuration name user.email.

git config –global user.name “username”

By using the –global flag, this example sets the value username for the current operating system user.

 

Exit mobile version