Home Explore Blog CI



git

6th chunk of `Documentation/git-config.adoc`
a1b313764f7681ee1aff2e4ef6b624725b4ac8339291fefb0000000100000bab
 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 attackers.

[[ENVIRONMENT]]
ENVIRONMENT
-----------

GIT_CONFIG_GLOBAL::
GIT_CONFIG_SYSTEM::
	Take the configuration from the given files instead from global or
	system-level configuration. See linkgit:git[1] for details.

GIT_CONFIG_NOSYSTEM::
	Whether to skip reading settings from the system-wide
	$(prefix)/etc/gitconfig file. See linkgit:git[1] for details.

See also <<FILES>>.

GIT_CONFIG_COUNT::
GIT_CONFIG_KEY_<n>::
GIT_CONFIG_VALUE_<n>::
	If GIT_CONFIG_COUNT is set to a positive number, all environment pairs
	GIT_CONFIG_KEY_<n> and GIT_CONFIG_VALUE_<n> up to that number will be
	added to the process's runtime configuration. The config pairs are
	zero-indexed. Any missing key or value is treated as an error. An empty
	GIT_CONFIG_COUNT is treated the same as GIT_CONFIG_COUNT=0, namely no
	pairs are processed. These environment variables will override values
	in configuration files, but will be overridden by any explicit options
	passed via `git -c`.
+
This is useful for cases where you want to spawn multiple git commands
with a common configuration but cannot depend on a configuration file,
for example when writing scripts.

GIT_CONFIG::
	If no `--file` option is provided to `git config`, use the file
	given by `GIT_CONFIG` as if it were provided via `--file`. This
	variable has no effect on other Git commands, and is mostly for
	historical compatibility; there is generally no reason to use it
	instead of the `--file` option.

[[EXAMPLES]]
EXAMPLES
--------

Given a .git/config like this:

------------
#
# This is the config file, and
# a '#' or ';' character indicates
# a comment
#

; core variables
[core]
	; Don't trust file modes
	filemode = false

; Our diff algorithm
[diff]
	external = /usr/local/bin/diff-wrapper
	renames = true

; Proxy settings
[core]
	gitproxy=proxy-command for kernel.org
	gitproxy=default-proxy ; for all the rest

; HTTP
[http]
	sslVerify
[http "https://weak.example.com"]
	sslVerify = false
	cookieFile = /tmp/cookie.txt

Title: Git Configuration Environment Variables and Examples
Summary
Git uses environment variables such as GIT_CONFIG_GLOBAL and GIT_CONFIG_NOSYSTEM to control configuration file usage, and variables like GIT_CONFIG_KEY_<n> and GIT_CONFIG_VALUE_<n> to override configuration values, with examples showing how to use these variables and configure Git settings in a .git/config file.