Git Configuration: Difference between revisions
Line 14: | Line 14: | ||
If no option is specified, <code>--local</code> is the default. | If no option is specified, <code>--local</code> is the default. | ||
If the same configuration element is specified in multiple locations, the most specific value becomes the effective value: a repository-level value takes precedence over a user-level values, which takes precedence over the corresponding system-level value. To obtain the effective value of a configuration element, execute < | If the same configuration element is specified in multiple locations, the most specific value becomes the effective value: a repository-level value takes precedence over a user-level values, which takes precedence over the corresponding system-level value. To obtain the effective value of a configuration element, execute: | ||
<syntaxhighlight lang='bash'> | |||
git config --get <config-element> | |||
</syntaxhighlight> | |||
A list of configuration elements is available in the [[#Configuration_Elements|Configuration Elements]] section. | |||
The configuration files are plain-text, so values can be set manually by editing the file and using the correct syntax. It’s generally easier to run the [[Git_config|git config]] command, though. | The configuration files are plain-text, so values can be set manually by editing the file and using the correct syntax. It’s generally easier to run the [[Git_config|git config]] command, though. |
Revision as of 22:32, 9 January 2024
Internal
Overview
Git maintains configuration in a hierarchy of files.
System-wide configuration is maintained in /etc/gitconfig
. This configuration applies to all users of the system and it is read and written by git config --system [...]
User-specific configuration is maintained in in ~/.gitconfig
or ~/.config/git/config
. This configuration applies to a specific user, and it is read and written by git config --global [...]
Repository specific configuration is maintained in .git/config
and it read and written with git config --local [...]
If no option is specified, --local
is the default.
If the same configuration element is specified in multiple locations, the most specific value becomes the effective value: a repository-level value takes precedence over a user-level values, which takes precedence over the corresponding system-level value. To obtain the effective value of a configuration element, execute:
git config --get <config-element>
A list of configuration elements is available in the Configuration Elements section.
The configuration files are plain-text, so values can be set manually by editing the file and using the correct syntax. It’s generally easier to run the git config command, though.