]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/config.txt
color: add support for 12-bit RGB colors
[thirdparty/git.git] / Documentation / config.txt
CommitLineData
1ab661dd
PB
1CONFIGURATION FILE
2------------------
3
2de9b711 4The Git configuration file contains a number of variables that affect
58b284a2 5the Git commands' behavior. The files `.git/config` and optionally
bdccbf70
MT
6`config.worktree` (see the "CONFIGURATION FILE" section of
7linkgit:git-worktree[1]) in each repository are used to store the
8configuration for that repository, and `$HOME/.gitconfig` is used to
9store a per-user configuration as fallback values for the `.git/config`
10file. The file `/etc/gitconfig` can be used to store a system-wide
11default configuration.
5ea5621f 12
2de9b711 13The configuration variables are used by both the Git plumbing
cf6cac20 14and the porcelain commands. The variables are divided into sections, wherein
b7ee2266 15the fully qualified variable name of the variable itself is the last
1ab661dd 16dot-separated segment and the section name is everything before the last
e0a4aae8
LP
17dot. The variable names are case-insensitive, allow only alphanumeric
18characters and `-`, and must start with an alphabetic character. Some
a5285b6c
JH
19variables may appear multiple times; we say then that the variable is
20multivalued.
1ab661dd 21
e136f33b
JN
22Syntax
23~~~~~~
24
e6895c3f
DS
25The syntax is fairly flexible and permissive. Whitespace characters,
26which in this context are the space character (SP) and the horizontal
27tabulation (HT), are mostly ignored. The '#' and ';' characters begin
28comments to the end of line. Blank lines are ignored.
e136f33b
JN
29
30The file consists of sections and variables. A section begins with
31the name of the section in square brackets and continues until the next
05c3e5c7 32section begins. Section names are case-insensitive. Only alphanumeric
dcb11263 33characters, `-` and `.` are allowed in section names. Each variable
773002a7
SB
34must belong to some section, which means that there must be a section
35header before the first setting of a variable.
e136f33b
JN
36
37Sections can be further divided into subsections. To begin a subsection
38put its name in double quotes, separated by space from the section name,
773002a7 39in the section header, like in the example below:
e136f33b
JN
40
41--------
42 [section "subsection"]
43
44--------
45
b7ee2266 46Subsection names are case sensitive and can contain any characters except
1feb0617
DB
47newline and the null byte. Doublequote `"` and backslash can be included
48by escaping them as `\"` and `\\`, respectively. Backslashes preceding
49other characters are dropped when reading; for example, `\t` is read as
cfd409ed 50`t` and `\0` is read as `0`. Section headers cannot span multiple lines.
1feb0617
DB
51Variables may belong directly to a section or to a given subsection. You
52can have `[section]` if you have `[section "subsection"]`, but you don't
53need to.
e136f33b 54
f7376329
CMN
55There is also a deprecated `[section.subsection]` syntax. With this
56syntax, the subsection name is converted to lower-case and is also
57compared case sensitively. These subsection names follow the same
58restrictions as section names.
e136f33b 59
2ceb639f
NS
60All the other lines (and the remainder of the line after the section
61header) are recognized as setting variables, in the form
1c448b3b
JH
62'name = value' (or just 'name', which is a short-hand to say that
63the variable is the boolean "true").
e0a4aae8 64The variable names are case-insensitive, allow only alphanumeric characters
a5285b6c 65and `-`, and must start with an alphabetic character.
e136f33b 66
e6895c3f
DS
67Whitespace characters surrounding `name`, `=` and `value` are discarded.
68Internal whitespace characters within 'value' are retained verbatim.
69Comments starting with either `#` or `;` and extending to the end of line
70are discarded. A line that defines a value can be continued to the next
71line by ending it with a backslash (`\`); the backslash and the end-of-line
72characters are discarded.
e136f33b 73
e6895c3f
DS
74If `value` needs to contain leading or trailing whitespace characters,
75it must be enclosed in double quotation marks (`"`). Inside double quotation
76marks, double quote (`"`) and backslash (`\`) characters must be escaped:
77use `\"` for `"` and `\\` for `\`.
e136f33b 78
dcb11263
CJ
79The following escape sequences (beside `\"` and `\\`) are recognized:
80`\n` for newline character (NL), `\t` for horizontal tabulation (HT, TAB)
a58088ab
JL
81and `\b` for backspace (BS). Other char escape sequences (including octal
82escape sequences) are invalid.
e136f33b 83
1ab661dd 84
9b25a0b5
JK
85Includes
86~~~~~~~~
87
9d71d94d
JK
88The `include` and `includeIf` sections allow you to include config
89directives from another source. These sections behave identically to
90each other with the exception that `includeIf` sections may be ignored
91if their condition does not evaluate to true; see "Conditional includes"
92below.
93
df0233be 94You can include a config file from another by setting the special
9d71d94d
JK
95`include.path` (or `includeIf.*.path`) variable to the name of the file
96to be included. The variable takes a pathname as its value, and is
97subject to tilde expansion. These variables can be given multiple times.
dca83abd 98
a076df28
JK
99The contents of the included file are inserted immediately, as if they
100had been found at the location of the include directive. If the value of the
9d71d94d 101variable is a relative path, the path is considered to
1050e987
NTND
102be relative to the configuration file in which the include directive
103was found. See below for examples.
dca83abd 104
3efd0bed
NTND
105Conditional includes
106~~~~~~~~~~~~~~~~~~~~
107
3771d002 108You can conditionally include a config file from another by setting an
3efd0bed 109`includeIf.<condition>.path` variable to the name of the file to be
9d71d94d 110included.
3efd0bed
NTND
111
112The condition starts with a keyword followed by a colon and some data
113whose format and meaning depends on the keyword. Supported keywords
114are:
115
116`gitdir`::
117
118 The data that follows the keyword `gitdir:` is used as a glob
119 pattern. If the location of the .git directory matches the
120 pattern, the include condition is met.
121+
122The .git location may be auto-discovered, or come from `$GIT_DIR`
0cac690e 123environment variable. If the repository is auto-discovered via a .git
3efd0bed
NTND
124file (e.g. from submodules, or a linked worktree), the .git location
125would be the final location where the .git directory is, not where the
126.git file is.
127+
128The pattern can contain standard globbing wildcards and two additional
129ones, `**/` and `/**`, that can match multiple path components. Please
130refer to linkgit:gitignore[5] for details. For convenience:
131
132 * If the pattern starts with `~/`, `~` will be substituted with the
133 content of the environment variable `HOME`.
134
135 * If the pattern starts with `./`, it is replaced with the directory
136 containing the current config file.
137
138 * If the pattern does not start with either `~/`, `./` or `/`, `**/`
139 will be automatically prepended. For example, the pattern `foo/bar`
140 becomes `**/foo/bar` and would match `/any/path/to/foo/bar`.
141
142 * If the pattern ends with `/`, `**` will be automatically added. For
143 example, the pattern `foo/` becomes `foo/**`. In other words, it
144 matches "foo" and everything inside, recursively.
145
146`gitdir/i`::
147 This is the same as `gitdir` except that matching is done
031fd4b9 148 case-insensitively (e.g. on case-insensitive file systems)
3efd0bed 149
07b2c0ea
DL
150`onbranch`::
151 The data that follows the keyword `onbranch:` is taken to be a
152 pattern with standard globbing wildcards and two additional
153 ones, `**/` and `/**`, that can match multiple path components.
154 If we are in a worktree where the name of the branch that is
155 currently checked out matches the pattern, the include condition
156 is met.
157+
158If the pattern ends with `/`, `**` will be automatically added. For
159example, the pattern `foo/` becomes `foo/**`. In other words, it matches
160all branches that begin with `foo/`. This is useful if your branches are
161organized hierarchically and you would like to apply a configuration to
162all the branches in that hierarchy.
163
399b1984
JT
164`hasconfig:remote.*.url:`::
165 The data that follows this keyword is taken to
166 be a pattern with standard globbing wildcards and two
167 additional ones, `**/` and `/**`, that can match multiple
168 components. The first time this keyword is seen, the rest of
169 the config files will be scanned for remote URLs (without
170 applying any values). If there exists at least one remote URL
171 that matches this pattern, the include condition is met.
172+
173Files included by this option (directly or indirectly) are not allowed
174to contain remote URLs.
175+
176Note that unlike other includeIf conditions, resolving this condition
177relies on information that is not yet known at the point of reading the
178condition. A typical use case is this option being present as a
179system-level or global-level config, and the remote URL being in a
180local-level config; hence the need to scan ahead when resolving this
181condition. In order to avoid the chicken-and-egg problem in which
182potentially-included files can affect whether such files are potentially
183included, Git breaks the cycle by prohibiting these files from affecting
184the resolution of these conditions (thus, prohibiting them from
185declaring remote URLs).
186+
548afb0d 187As for the naming of this keyword, it is for forwards compatibility with
399b1984
JT
188a naming scheme that supports more variable-based include conditions,
189but currently Git only supports the exact keyword described above.
190
3efd0bed
NTND
191A few more notes on matching via `gitdir` and `gitdir/i`:
192
193 * Symlinks in `$GIT_DIR` are not resolved before matching.
194
0624c63c
ÆAB
195 * Both the symlink & realpath versions of paths will be matched
196 outside of `$GIT_DIR`. E.g. if ~/git is a symlink to
197 /mnt/storage/git, both `gitdir:~/git` and `gitdir:/mnt/storage/git`
198 will match.
199+
200This was not the case in the initial release of this feature in
201v2.13.0, which only matched the realpath version. Configuration that
202wants to be compatible with the initial release of this feature needs
203to either specify only the realpath version, or both versions.
204
3efd0bed
NTND
205 * Note that "../" is not special and will match literally, which is
206 unlikely what you want.
9b25a0b5 207
1ab661dd
PB
208Example
209~~~~~~~
210
1925fe0c
211----
212# Core variables
213[core]
214 ; Don't trust file modes
215 filemode = false
216
217# Our diff algorithm
218[diff]
219 external = /usr/local/bin/diff-wrapper
220 renames = true
221
222[branch "devel"]
223 remote = origin
224 merge = refs/heads/devel
225
226# Proxy settings
227[core]
228 gitProxy="ssh" for "kernel.org"
229 gitProxy=default-proxy ; for the rest
230
231[include]
232 path = /path/to/foo.inc ; include by absolute path
233 path = foo.inc ; find "foo.inc" relative to the current file
234 path = ~/foo.inc ; find "foo.inc" in your `$HOME` directory
235
236; include if $GIT_DIR is /path/to/foo/.git
237[includeIf "gitdir:/path/to/foo/.git"]
238 path = /path/to/foo.inc
239
240; include for all repositories inside /path/to/group
241[includeIf "gitdir:/path/to/group/"]
242 path = /path/to/foo.inc
243
244; include for all repositories inside $HOME/to/group
245[includeIf "gitdir:~/to/group/"]
246 path = /path/to/foo.inc
247
248; relative paths are always relative to the including
249; file (if the condition is true); their location is not
250; affected by the condition
251[includeIf "gitdir:/path/to/group/"]
252 path = foo.inc
994cd6c7 253
76ba7fa2
254; include only if we are in a worktree where foo-branch is
255; currently checked out
256[includeIf "onbranch:foo-branch"]
257 path = foo.inc
399b1984
JT
258
259; include only if a remote with the given URL exists (note
260; that such a URL may be provided later in a file or in a
261; file read after this file is read, as seen in this example)
262[includeIf "hasconfig:remote.*.url:https://example.com/**"]
263 path = foo.inc
264[remote "origin"]
265 url = https://example.com/git
76ba7fa2 266----
07b2c0ea 267
5f7b91ba
JH
268Values
269~~~~~~
270
271Values of many variables are treated as a simple string, but there
272are variables that take values of specific types and there are rules
273as to how to spell them.
274
275boolean::
276
277 When a variable is said to take a boolean value, many
278 synonyms are accepted for 'true' and 'false'; these are all
279 case-insensitive.
280
7f0a02be
AH
281 true;; Boolean true literals are `yes`, `on`, `true`,
282 and `1`. Also, a variable defined without `= <value>`
5f7b91ba
JH
283 is taken as true.
284
7f0a02be
AH
285 false;; Boolean false literals are `no`, `off`, `false`,
286 `0` and the empty string.
5f7b91ba 287+
ed3bb3df 288When converting a value to its canonical form using the `--type=bool` type
7f0a02be 289specifier, 'git config' will ensure that the output is "true" or
5f7b91ba
JH
290"false" (spelled in lowercase).
291
292integer::
293 The value for many variables that specify various sizes can
294 be suffixed with `k`, `M`,... to mean "scale the number by
295 1024", "by 1024x1024", etc.
296
b92c1a28 297color::
adb33566
JK
298 The value for a variable that takes a color is a list of
299 colors (at most two, one for foreground and one for background)
300 and attributes (as many as you want), separated by spaces.
5f456b3c 301+
05f1f41c
RE
302The basic colors accepted are `normal`, `black`, `red`, `green`,
303`yellow`, `blue`, `magenta`, `cyan`, `white` and `default`. The first
304color given is the foreground; the second is the background. All the
305basic colors except `normal` and `default` have a bright variant that can
306be specified by prefixing the color with `bright`, like `brightred`.
307+
308The color `normal` makes no change to the color. It is the same as an
309empty string, but can be used as the foreground color when specifying a
310background color alone (for example, "normal red").
311+
312The color `default` explicitly resets the color to the terminal default,
313for example to specify a cleared background. Although it varies between
314terminals, this is usually not the same as setting to "white black".
5ee87585 315+
adb33566
JK
316Colors may also be given as numbers between 0 and 255; these use ANSI
317256-color mode (but note that not all terminals may support this). If
318your terminal supports it, you may also specify 24-bit RGB values as
7b97dfe4
BB
319hex, like `#ff0ab3`, or 12-bit RGB values like `#f1b`, which is
320equivalent to the 24-bit color `#ff11bb`.
adb33566 321+
9dc3515c
JK
322The accepted attributes are `bold`, `dim`, `ul`, `blink`, `reverse`,
323`italic`, and `strike` (for crossed-out or "strikethrough" letters).
324The position of any attributes with respect to the colors
54590a0e
JK
325(before, after, or in between), doesn't matter. Specific attributes may
326be turned off by prefixing them with `no` or `no-` (e.g., `noreverse`,
327`no-ul`, etc).
adb33566 328+
de658515
RE
329The pseudo-attribute `reset` resets all colors and attributes before
330applying the specified coloring. For example, `reset green` will result
331in a green foreground and default background without any active
332attributes.
333+
512aba26
JK
334An empty color string produces no color effect at all. This can be used
335to avoid coloring specific elements without disabling color entirely.
336+
adb33566
JK
337For git's pre-defined color slots, the attributes are meant to be reset
338at the beginning of each item in the colored output. So setting
339`color.decorate.branch` to `black` will paint that branch name in a
340plain `black`, even if the previous thing on the same output line (e.g.
341opening parenthesis before the list of branch names in `log --decorate`
342output) is set to be painted with `bold` or some other attribute.
343However, custom log formats may do more complicated and layered
344coloring, and the negated forms may be useful there.
b92c1a28 345
dca83abd
JH
346pathname::
347 A variable that takes a pathname value can be given a
348 string that begins with "`~/`" or "`~user/`", and the usual
349 tilde expansion happens to such a string: `~/`
350 is expanded to the value of `$HOME`, and `~user/` to the
351 specified user's home directory.
e394a160
JS
352+
353If a path starts with `%(prefix)/`, the remainder is interpreted as a
354path relative to Git's "runtime prefix", i.e. relative to the location
355where Git itself was installed. For example, `%(prefix)/bin/` refers to
356the directory in which the Git executable itself lives. If Git was
357compiled without runtime prefix support, the compiled-in prefix will be
480f0541 358substituted instead. In the unlikely event that a literal path needs to
e394a160
JS
359be specified that should _not_ be expanded, it needs to be prefixed by
360`./`, like so: `./%(prefix)/bin`.
dca83abd 361
5f7b91ba 362
1ab661dd
PB
363Variables
364~~~~~~~~~
365
366Note that this list is non-comprehensive and not necessarily complete.
b8936cf0 367For command-specific variables, you will find a more detailed description
93728b23
CA
368in the appropriate manual page.
369
370Other git-related tools may and do use their own variables. When
371inventing new variables for use in your own tool, make sure their
372names do not conflict with those that are used by Git itself and
373other popular tools, and describe them in your documentation.
374
29120d8e 375include::config/add.txt[]
13bd2134 376
5f78d52d
ES
377include::config/advice.txt[]
378
f740c8f1 379include::config/alias.txt[]
dfd42a3c 380
d293ffef 381include::config/am.txt[]
e97a5e76 382
696d4796 383include::config/apply.txt[]
1ab661dd 384
5f78d52d
ES
385include::config/attr.txt[]
386
d09467b6 387include::config/blame.txt[]
8578037b 388
7273b95d 389include::config/branch.txt[]
a5ba2cbe 390
6b0b9740 391include::config/browser.txt[]
584627b4 392
bff03c47
DS
393include::config/bundle.txt[]
394
9140b410 395include::config/checkout.txt[]
fa655d84 396
328e629c 397include::config/clean.txt[]
2122591b 398
de9ed3ef
SB
399include::config/clone.txt[]
400
0a7839e3 401include::config/color.txt[]
6b2f2d98 402
dbfc949f 403include::config/column.txt[]
d96e3c15 404
5453d236 405include::config/commit.txt[]
aaab8420 406
b66d8475
TB
407include::config/commitgraph.txt[]
408
2b4b7305 409include::config/completion.txt[]
6532f374 410
5f78d52d
ES
411include::config/core.txt[]
412
413include::config/credential.txt[]
414
fa922d74 415include::config/diff.txt[]
afcbc8e7 416
9155f6f6 417include::config/difftool.txt[]
a904392e 418
4feb562f 419include::config/extensions.txt[]
420
f2e58246 421include::config/fastimport.txt[]
d9545c7f 422
c6cc4c5a
DS
423include::config/feature.txt[]
424
561fda20 425include::config/fetch.txt[]
42cc7485 426
734dfebb 427include::config/filter.txt[]
26488f59 428
5f78d52d
ES
429include::config/format.txt[]
430
f80ccccb 431include::config/fsck.txt[]
1335f732 432
5aa9e326
ED
433include::config/fsmonitor--daemon.txt[]
434
8daf3271 435include::config/gc.txt[]
48c32424 436
996f66eb 437include::config/gitcvs.txt[]
04752868 438
0648b769 439include::config/gitweb.txt[]
cd82323f 440
ea555d04 441include::config/gpg.txt[]
b02f51b1 442
5f78d52d
ES
443include::config/grep.txt[]
444
d864cf8b 445include::config/gui.txt[]
a2df1fb2 446
2c31a830 447include::config/guitool.txt[]
390c3480 448
d3df4270 449include::config/help.txt[]
b1f809d0 450
ad308479 451include::config/http.txt[]
6a56993b 452
8fc3f75f 453include::config/i18n.txt[]
d2c11a38 454
ae461026 455include::config/imap.txt[]
b0f34c3d 456
07aed580
MB
457include::config/includeif.txt[]
458
c1b342ad 459include::config/index.txt[]
3c09d684 460
ec335607 461include::config/init.txt[]
d8a8488d 462
cef9b951 463include::config/instaweb.txt[]
983a9eeb 464
630c2738 465include::config/interactive.txt[]
01143847 466
83009762 467include::config/log.txt[]
e6bb5f78 468
59e1205d
JT
469include::config/lsrefs.txt[]
470
55e51cd7 471include::config/mailinfo.txt[]
d5c4b185 472
4a9f0c52 473include::config/mailmap.txt[]
08610900 474
65d655b5
DS
475include::config/maintenance.txt[]
476
f7ade6c9 477include::config/man.txt[]
7e8114c0 478
7fb5ab4a 479include::config/merge.txt[]
b5412484 480
ea24a76a 481include::config/mergetool.txt[]
682b451f 482
e50472d8 483include::config/notes.txt[]
6956f858 484
a168c5a2 485include::config/pack.txt[]
ae4f07fb 486
87e1b41a 487include::config/pager.txt[]
4370c2d6 488
cd967547 489include::config/pretty.txt[]
8028184e 490
dd55172c 491include::config/protocol.txt[]
373d70ef 492
7f50a495 493include::config/pull.txt[]
d8052750 494
d15dc439 495include::config/push.txt[]
b33a15b0 496
c7245900 497include::config/rebase.txt[]
16cf51c7 498
5f5a5fca 499include::config/receive.txt[]
0a1bc12b 500
99fce397 501include::config/remote.txt[]
737c5a9c 502
b720a9db 503include::config/remotes.txt[]
1918278e 504
be958be2 505include::config/repack.txt[]
ee34a2be 506
72622c24 507include::config/rerere.txt[]
b0f34c3d 508
fc0f8bcd
RS
509include::config/revert.txt[]
510
8959555c
JS
511include::config/safe.txt[]
512
0ee42c86 513include::config/sendemail.txt[]
5453b83b 514
c3324199 515include::config/sequencer.txt[]
8dc9d22d 516
c52bcbb6 517include::config/showbranch.txt[]
1ab661dd 518
ecc7c884
EN
519include::config/sparse.txt[]
520
2ef0e469 521include::config/splitindex.txt[]
b2dd1c5c 522
12e60249
NTND
523include::config/ssh.txt[]
524
46a8bbb2 525include::config/stash.txt[]
3086c064 526
5f78d52d
ES
527include::config/status.txt[]
528
95c125f2 529include::config/submodule.txt[]
31224cbd 530
fb4c06fa 531include::config/tag.txt[]
ce1a79b6 532
8312aa7d
JH
533include::config/tar.txt[]
534
81567caf
JH
535include::config/trace2.txt[]
536
4a5bad07 537include::config/transfer.txt[]
b0f34c3d 538
c61f5562 539include::config/uploadarchive.txt[]
7671b632 540
533fff6a 541include::config/uploadpack.txt[]
516e2b76 542
e4a7a7b0 543include::config/url.txt[]
1c2eafb8 544
18b421d4 545include::config/user.txt[]
d67778ec 546
25268ad5 547include::config/versionsort.txt[]
d811c8e1 548
07c11a0b 549include::config/web.txt[]
e92445a7 550
649cf589 551include::config/worktree.txt[]