Google News
logo
Git - Interview Questions
Explain the levels in git config and how can you configure values using them?
In order to make git work, it uses a set of configurations that are pre-defined by default by means of configuration files (or config files). We can change the default behavior of git by just modifying these files which are basically text files. In order to do this, it is important to understand how git identifies these files. It does so by following the below steps :
 
- Firstly, git searches for the config values in the system-wide gitconfig file stored in <<installation_path>>/etc/gitconfig file that has settings defined and applied to every user of the system and all their repos.

     - In case you want git to search from this particular file and read/write on it, we can pass the option --system to git config command.
 
- Next, git searches for the ~/.gitconfig file or ~/.config/git/config that has the scope specific to the user.

   - Git can be made to read/ write from this file specifically bypassing --global to the git config command.
 
- Lastly, git searches for the config values in the git directory of the local repository that we are currently working on.

   - These config values are specific to that particular repository alone and can be accessed by passing --local to the git config command.This is the default config file that gets accessed and modified upon in case we do not specify any levels.
Advertisement