Git Configuration: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 10: Line 10:
User-specific configuration is maintained in in <code>~/[[.gitconfig#Overview|.gitconfig]]</code> or <code>~/[[.config/git/config#Overview|.config/git/config]]</code>. This configuration applies to a specific user, and it is read and written by <code>git config --global [...]</code>
User-specific configuration is maintained in in <code>~/[[.gitconfig#Overview|.gitconfig]]</code> or <code>~/[[.config/git/config#Overview|.config/git/config]]</code>. This configuration applies to a specific user, and it is read and written by <code>git config --global [...]</code>


Repository specific configuration is maintained in <code>[[.git/config#Overview|.git/config]]</code> and it read and written with <code>git config --local [...]</code>


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 <code>[[Git_config#Get_a_Setting|git config --get]]</code>.


 
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.
 
Repository specific configuration is maintained in <code>[[.git/config#Overview|.git/config]]</code>.
 
 
 
Repository specific configuration is read and written with <tt>git config --local ...</tt>. If no option is specified, --local is the default.
 
If specified in multiple location, a configuration element is resolved to the most specific value: a repository-level value takes precedence over a user-level values, and a user-level value takes precedence over the corresponding system-level value. To use the effective value of a configuration element, use [[Git_config#Get_a_Setting|git config --get]].
 
The configuration files are plain-text, so values can be set manually by editing the file and inserting the correct syntax. It’s generally easier to run the [[Git_config|git config]] command, though.


=Files=
=Files=

Revision as of 22:26, 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.

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.

Files

Environment Variables

Git Environment Variables

Configuration Options

Git Configuration Options

Configuration Operations

git config Configuration Operations