Git Configuration: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 4: Line 4:


=Overview=
=Overview=
Git maintains configuration in a hierarchy of files that includes system-wide configuration stored in <code>/etc/gitconfig</code>, user-specific configuration stored in <code>~/.gitconfig</code> or <code>~/.config/git/config</code> and repository specific configuration in stored in <code>.git/config</code>.


git maintains configuration in a hierarchy of files, from system-wide configuration in <tt>/etc/gitconfig</tt>, user-specific configuration in <tt>~/.gitconfig</tt> or <tt>~/.config/git/config</tt>, to repository specific configuration in <tt>.git/config</tt>.


<tt>/etc/gitconfig</tt> contains configuration that applies to all users of the system. <tt>git config --system ...</tt> reads and writes this file. User-specific configuration is read and written with <tt>git config --global ...</tt>. Repository specific configuration is read and written with <tt>git config --local ...</tt>. If no option is specified, --local is the default.
<tt>/etc/gitconfig</tt> contains configuration that applies to all users of the system. <tt>git config --system ...</tt> reads and writes this file. User-specific configuration is read and written with <tt>git config --global ...</tt>. Repository specific configuration is read and written with <tt>git config --local ...</tt>. If no option is specified, --local is the default.
Line 12: Line 14:


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.
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=
* <code>[[.gitconfig]]</code>
* <code>[[.gitconfig]]</code>

Revision as of 22:10, 9 January 2024

Internal

Overview

Git maintains configuration in a hierarchy of files that includes system-wide configuration stored in /etc/gitconfig, user-specific configuration stored in ~/.gitconfig or ~/.config/git/config and repository specific configuration in stored in .git/config.



/etc/gitconfig contains configuration that applies to all users of the system. git config --system ... reads and writes this file. User-specific configuration is read and written with git config --global .... Repository specific configuration is read and written with git config --local .... 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.

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 command, though.

Files

Environment Variables

Git Environment Variables

Configuration Options

Git Configuration Options

Configuration Operations

git config Configuration Operations