Git settings configuration
Start your free 7-days trial now!
It is possible to check and change Git settings using the git config
command.
There are three types of settings:
Type | Scope | Location | Notes |
---|---|---|---|
system | All repositories for every user on this computer. |
| - |
global | All repositories of a particular user |
| Directly below home |
local | A specific repository |
| Under |
Settings take precedence in the following order: local, global, system. For example, if the same setting is configured in both system and local, the value of local will be used.
You can view the list of all configurable settings from the official documentation: https://git-scm.com/docs/git-config.html#_variables
A few examples include:
color.ui
: controls Git output color coding (set toauto
by default)core.editor
: editor used for editing commit messages
Checking settings configuration
Single variable
You can check the current configuration for each variable using the following command:
git config <name>
where <name>
refers to the name of the variable you would like to check the configuration for.
For example, to check the current configuration for the core.editor
variable:
git config core.editor
To check the configuration at a particular level (local, system, global):
git config --local core.editorgit config --global core.editorgit config --system core.editor
As local is a per repository setting, the --local
option is only valid when the command is run within the repository.
All configured variables
To display all configured variables and their values that are enabled at the place where the command is executed:
git config -l
credential.helper=osxkeychain
Again, it is possible to just check the configurations at a particular level (local, system, global):
git config --local -lgit config --global -lgit config --system -l
Modifying settings configuration
To change the configuration of a particular variable:
git config <name> <value>
where:
<name>
refers to the name of the variable you would like to check the configuration for<value>
refers to the new value to set for the variable
By default, running the above command will change the local configurations.
To change the global, system configurations of a particular variable:
git config --global <name> <value>git config --system <name> <value>