Home Explore Blog CI



git

5th chunk of `Documentation/git-config.adoc`
6020666dd3d4ff3d2b4821d95007da9885af50190179d0530000000100000fa0
 --append <name> <value>`.

--unset <name> [<value-pattern>]::
	Replaced by `git config unset [--value=<pattern>] <name>`.

--unset-all <name> [<value-pattern>]::
	Replaced by `git config unset [--value=<pattern>] --all <name>`.

--rename-section <old-name> <new-name>::
	Replaced by `git config rename-section <old-name> <new-name>`.

--remove-section <name>::
	Replaced by `git config remove-section <name>`.

-e::
--edit::
	Replaced by `git config edit`.

CONFIGURATION
-------------
`pager.config` is only respected when listing configuration, i.e., when
using `list` or `get` which may return multiple results. The default is to use
a pager.

[[FILES]]
FILES
-----

By default, 'git config' will read configuration options from multiple
files:

$(prefix)/etc/gitconfig::
	System-wide configuration file.

$XDG_CONFIG_HOME/git/config::
~/.gitconfig::
	User-specific configuration files. When the XDG_CONFIG_HOME environment
	variable is not set or empty, $HOME/.config/ is used as
	$XDG_CONFIG_HOME.
+
These are also called "global" configuration files. If both files exist, both
files are read in the order given above.

$GIT_DIR/config::
	Repository specific configuration file.

$GIT_DIR/config.worktree::
	This is optional and is only searched when
	`extensions.worktreeConfig` is present in $GIT_DIR/config.

You may also provide additional configuration parameters when running any
git command by using the `-c` option. See linkgit:git[1] for details.

Options will be read from all of these files that are available. If the
global or the system-wide configuration files are missing or unreadable they
will be ignored. If the repository configuration file is missing or unreadable,
'git config' will exit with a non-zero error code. An error message is produced
if the file is unreadable, but not if it is missing.

The files are read in the order given above, with last value found taking
precedence over values read earlier.  When multiple values are taken then all
values of a key from all files will be used.

By default, options are only written to the repository specific
configuration file. Note that this also affects options like `set`
and `unset`. *'git config' will only ever change one file at a time*.

You can limit which configuration sources are read from or written to by
specifying the path of a file with the `--file` option, or by specifying a
configuration scope with `--system`, `--global`, `--local`, or `--worktree`.
For more, see <<OPTIONS>> above.

[[SCOPES]]
SCOPES
------

Each configuration source falls within a configuration scope. The scopes
are:

system::
	$(prefix)/etc/gitconfig

global::
	$XDG_CONFIG_HOME/git/config
+
~/.gitconfig

local::
	$GIT_DIR/config

worktree::
	$GIT_DIR/config.worktree

command::
	GIT_CONFIG_{COUNT,KEY,VALUE} environment variables (see <<ENVIRONMENT>>
	below)
+
the `-c` option

With the exception of 'command', each scope corresponds to a command line
option: `--system`, `--global`, `--local`, `--worktree`.

When reading options, specifying a scope will only read options from the
files within that scope. When writing options, specifying a scope will write
to the files within that scope (instead of the repository specific
configuration file). See <<OPTIONS>> above for a complete description.

Most configuration options are respected regardless of the scope it is
defined in, but some options are only respected in certain scopes. See the
respective option's documentation for the full details.

Protected configuration
~~~~~~~~~~~~~~~~~~~~~~~

Protected configuration refers to the 'system', 'global', and 'command' scopes.
For security reasons, certain options are only respected when they are
specified in protected configuration, and ignored otherwise.

Git treats these scopes as if they are controlled by the user or a trusted
administrator. This is because an attacker who controls these scopes can do
substantial harm without using Git, so it is assumed that the user's environment
protects these scopes against

Title: Git Configuration Files, Scopes, and Protected Configuration
Summary
The git config command reads options from multiple files, including system-wide, global, and repository-specific configuration files, with each file having a specific scope, and some options are only respected in certain scopes or protected configuration for security reasons.