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