Home Explore Blog CI



git

2nd chunk of `Documentation/git-config.adoc`
25e76ef0bbe7d2d7e9ee9a1dcf115f00da22b546ce5b4be20000000100000fa8
 value of the specified key. If key is present multiple times
	in the configuration, emits the last value. If `--all` is specified,
	emits all values associated with key. Returns error code 1 if key is
	not present.

set::
	Set value for one or more config options. By default, this command
	refuses to write multi-valued config options. Passing `--all` will
	replace all multi-valued config options with the new value, whereas
	`--value=` will replace all config options whose values match the given
	pattern.

unset::
	Unset value for one or more config options. By default, this command
	refuses to unset multi-valued keys. Passing `--all` will unset all
	multi-valued config options, whereas `--value` will unset all config
	options whose values match the given pattern.

rename-section::
	Rename the given section to a new name.

remove-section::
	Remove the given section from the configuration file.

edit::
	Opens an editor to modify the specified config file; either
	`--system`, `--global`, `--local` (default), `--worktree`, or
	`--file <config-file>`.

[[OPTIONS]]
OPTIONS
-------

--replace-all::
	Default behavior is to replace at most one line. This replaces
	all lines matching the key (and optionally the `value-pattern`).

--append::
	Adds a new line to the option without altering any existing
	values. This is the same as providing '--value=^$' in `set`.

--comment <message>::
	Append a comment at the end of new or modified lines.

	If _<message>_ begins with one or more whitespaces followed
	by "#", it is used as-is.  If it begins with "#", a space is
	prepended before it is used.  Otherwise, a string " # " (a
	space followed by a hash followed by a space) is prepended
	to it.  And the resulting string is placed immediately after
	the value defined for the variable.  The _<message>_ must
	not contain linefeed characters (no multi-line comments are
	permitted).

--all::
	With `get`, return all values for a multi-valued key.

--regexp::
	With `get`, interpret the name as a regular expression. Regular
	expression matching is currently case-sensitive and done against a
	canonicalized version of the key in which section and variable names
	are lowercased, but subsection names are not.

--url=<URL>::
	When given a two-part <name> as <section>.<key>, the value for
	<section>.<URL>.<key> whose <URL> part matches the best to the
	given URL is returned (if no such key exists, the value for
	<section>.<key> is used as a fallback).  When given just the
	<section> as name, do so for all the keys in the section and
	list them.  Returns error code 1 if no value is found.

--global::
	For writing options: write to global `~/.gitconfig` file
	rather than the repository `.git/config`, write to
	`$XDG_CONFIG_HOME/git/config` file if this file exists and the
	`~/.gitconfig` file doesn't.
+
For reading options: read only from global `~/.gitconfig` and from
`$XDG_CONFIG_HOME/git/config` rather than from all available files.
+
See also <<FILES>>.

--system::
	For writing options: write to system-wide
	`$(prefix)/etc/gitconfig` rather than the repository
	`.git/config`.
+
For reading options: read only from system-wide `$(prefix)/etc/gitconfig`
rather than from all available files.
+
See also <<FILES>>.

--local::
	For writing options: write to the repository `.git/config` file.
	This is the default behavior.
+
For reading options: read only from the repository `.git/config` rather than
from all available files.
+
See also <<FILES>>.

--worktree::
	Similar to `--local` except that `$GIT_DIR/config.worktree` is
	read from or written to if `extensions.worktreeConfig` is
	enabled. If not it's the same as `--local`. Note that `$GIT_DIR`
	is equal to `$GIT_COMMON_DIR` for the main working tree, but is of
	the form `$GIT_DIR/worktrees/<id>/` for other working trees. See
	linkgit:git-worktree[1] to learn how to enable
	`extensions.worktreeConfig`.

-f <config-file>::
--file <config-file>::
	For writing options: write to the specified file rather than the
	repository

Title: Git Config Options and Commands
Summary
The git config command provides various options and sub-commands to manage Git configuration files, including setting, getting, and unsetting values, renaming sections, and editing config files, with flags to control the scope and behavior of these operations.