]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/config.txt
Merge branch 'rs/midx-use-strvec-pushf'
[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
319hex, like `#ff0ab3`.
320+
9dc3515c
JK
321The accepted attributes are `bold`, `dim`, `ul`, `blink`, `reverse`,
322`italic`, and `strike` (for crossed-out or "strikethrough" letters).
323The position of any attributes with respect to the colors
54590a0e
JK
324(before, after, or in between), doesn't matter. Specific attributes may
325be turned off by prefixing them with `no` or `no-` (e.g., `noreverse`,
326`no-ul`, etc).
adb33566 327+
de658515
RE
328The pseudo-attribute `reset` resets all colors and attributes before
329applying the specified coloring. For example, `reset green` will result
330in a green foreground and default background without any active
331attributes.
332+
512aba26
JK
333An empty color string produces no color effect at all. This can be used
334to avoid coloring specific elements without disabling color entirely.
335+
adb33566
JK
336For git's pre-defined color slots, the attributes are meant to be reset
337at the beginning of each item in the colored output. So setting
338`color.decorate.branch` to `black` will paint that branch name in a
339plain `black`, even if the previous thing on the same output line (e.g.
340opening parenthesis before the list of branch names in `log --decorate`
341output) is set to be painted with `bold` or some other attribute.
342However, custom log formats may do more complicated and layered
343coloring, and the negated forms may be useful there.
b92c1a28 344
dca83abd
JH
345pathname::
346 A variable that takes a pathname value can be given a
347 string that begins with "`~/`" or "`~user/`", and the usual
348 tilde expansion happens to such a string: `~/`
349 is expanded to the value of `$HOME`, and `~user/` to the
350 specified user's home directory.
e394a160
JS
351+
352If a path starts with `%(prefix)/`, the remainder is interpreted as a
353path relative to Git's "runtime prefix", i.e. relative to the location
354where Git itself was installed. For example, `%(prefix)/bin/` refers to
355the directory in which the Git executable itself lives. If Git was
356compiled without runtime prefix support, the compiled-in prefix will be
480f0541 357substituted instead. In the unlikely event that a literal path needs to
e394a160
JS
358be specified that should _not_ be expanded, it needs to be prefixed by
359`./`, like so: `./%(prefix)/bin`.
dca83abd 360
5f7b91ba 361
1ab661dd
PB
362Variables
363~~~~~~~~~
364
365Note that this list is non-comprehensive and not necessarily complete.
b8936cf0 366For command-specific variables, you will find a more detailed description
93728b23
CA
367in the appropriate manual page.
368
369Other git-related tools may and do use their own variables. When
370inventing new variables for use in your own tool, make sure their
371names do not conflict with those that are used by Git itself and
372other popular tools, and describe them in your documentation.
373
29120d8e 374include::config/add.txt[]
13bd2134 375
5f78d52d
ES
376include::config/advice.txt[]
377
f740c8f1 378include::config/alias.txt[]
dfd42a3c 379
d293ffef 380include::config/am.txt[]
e97a5e76 381
696d4796 382include::config/apply.txt[]
1ab661dd 383
5f78d52d
ES
384include::config/attr.txt[]
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
2b4b7305 408include::config/completion.txt[]
6532f374 409
5f78d52d
ES
410include::config/core.txt[]
411
412include::config/credential.txt[]
413
fa922d74 414include::config/diff.txt[]
afcbc8e7 415
9155f6f6 416include::config/difftool.txt[]
a904392e 417
4feb562f 418include::config/extensions.txt[]
419
f2e58246 420include::config/fastimport.txt[]
d9545c7f 421
c6cc4c5a
DS
422include::config/feature.txt[]
423
561fda20 424include::config/fetch.txt[]
42cc7485 425
734dfebb 426include::config/filter.txt[]
26488f59 427
5f78d52d
ES
428include::config/format.txt[]
429
f80ccccb 430include::config/fsck.txt[]
1335f732 431
5aa9e326
ED
432include::config/fsmonitor--daemon.txt[]
433
8daf3271 434include::config/gc.txt[]
48c32424 435
996f66eb 436include::config/gitcvs.txt[]
04752868 437
0648b769 438include::config/gitweb.txt[]
cd82323f 439
ea555d04 440include::config/gpg.txt[]
b02f51b1 441
5f78d52d
ES
442include::config/grep.txt[]
443
d864cf8b 444include::config/gui.txt[]
a2df1fb2 445
2c31a830 446include::config/guitool.txt[]
390c3480 447
d3df4270 448include::config/help.txt[]
b1f809d0 449
ad308479 450include::config/http.txt[]
6a56993b 451
8fc3f75f 452include::config/i18n.txt[]
d2c11a38 453
ae461026 454include::config/imap.txt[]
b0f34c3d 455
07aed580
MB
456include::config/includeif.txt[]
457
c1b342ad 458include::config/index.txt[]
3c09d684 459
ec335607 460include::config/init.txt[]
d8a8488d 461
cef9b951 462include::config/instaweb.txt[]
983a9eeb 463
630c2738 464include::config/interactive.txt[]
01143847 465
83009762 466include::config/log.txt[]
e6bb5f78 467
59e1205d
JT
468include::config/lsrefs.txt[]
469
55e51cd7 470include::config/mailinfo.txt[]
d5c4b185 471
4a9f0c52 472include::config/mailmap.txt[]
08610900 473
65d655b5
DS
474include::config/maintenance.txt[]
475
f7ade6c9 476include::config/man.txt[]
7e8114c0 477
7fb5ab4a 478include::config/merge.txt[]
b5412484 479
ea24a76a 480include::config/mergetool.txt[]
682b451f 481
e50472d8 482include::config/notes.txt[]
6956f858 483
a168c5a2 484include::config/pack.txt[]
ae4f07fb 485
87e1b41a 486include::config/pager.txt[]
4370c2d6 487
cd967547 488include::config/pretty.txt[]
8028184e 489
dd55172c 490include::config/protocol.txt[]
373d70ef 491
7f50a495 492include::config/pull.txt[]
d8052750 493
d15dc439 494include::config/push.txt[]
b33a15b0 495
c7245900 496include::config/rebase.txt[]
16cf51c7 497
5f5a5fca 498include::config/receive.txt[]
0a1bc12b 499
99fce397 500include::config/remote.txt[]
737c5a9c 501
b720a9db 502include::config/remotes.txt[]
1918278e 503
be958be2 504include::config/repack.txt[]
ee34a2be 505
72622c24 506include::config/rerere.txt[]
b0f34c3d 507
fc0f8bcd
RS
508include::config/revert.txt[]
509
8959555c
JS
510include::config/safe.txt[]
511
0ee42c86 512include::config/sendemail.txt[]
5453b83b 513
c3324199 514include::config/sequencer.txt[]
8dc9d22d 515
c52bcbb6 516include::config/showbranch.txt[]
1ab661dd 517
ecc7c884
EN
518include::config/sparse.txt[]
519
2ef0e469 520include::config/splitindex.txt[]
b2dd1c5c 521
12e60249
NTND
522include::config/ssh.txt[]
523
46a8bbb2 524include::config/stash.txt[]
3086c064 525
5f78d52d
ES
526include::config/status.txt[]
527
95c125f2 528include::config/submodule.txt[]
31224cbd 529
fb4c06fa 530include::config/tag.txt[]
ce1a79b6 531
8312aa7d
JH
532include::config/tar.txt[]
533
81567caf
JH
534include::config/trace2.txt[]
535
4a5bad07 536include::config/transfer.txt[]
b0f34c3d 537
c61f5562 538include::config/uploadarchive.txt[]
7671b632 539
533fff6a 540include::config/uploadpack.txt[]
516e2b76 541
e4a7a7b0 542include::config/url.txt[]
1c2eafb8 543
18b421d4 544include::config/user.txt[]
d67778ec 545
25268ad5 546include::config/versionsort.txt[]
d811c8e1 547
07c11a0b 548include::config/web.txt[]
e92445a7 549
649cf589 550include::config/worktree.txt[]