]> git.ipfire.org Git - thirdparty/git.git/blame_incremental - Documentation/config.txt
Merge branch 'tb/ci-run-cocci-with-18.04' into maint
[thirdparty/git.git] / Documentation / config.txt
... / ...
CommitLineData
1CONFIGURATION FILE
2------------------
3
4The Git configuration file contains a number of variables that affect
5the Git commands' behavior. The files `.git/config` and optionally
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.
12
13The configuration variables are used by both the Git plumbing
14and the porcelains. The variables are divided into sections, wherein
15the fully qualified variable name of the variable itself is the last
16dot-separated segment and the section name is everything before the last
17dot. The variable names are case-insensitive, allow only alphanumeric
18characters and `-`, and must start with an alphabetic character. Some
19variables may appear multiple times; we say then that the variable is
20multivalued.
21
22Syntax
23~~~~~~
24
25The syntax is fairly flexible and permissive; whitespaces are mostly
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
31section begins. Section names are case-insensitive. Only alphanumeric
32characters, `-` and `.` are allowed in section names. Each variable
33must belong to some section, which means that there must be a section
34header before the first setting of a variable.
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,
38in the section header, like in the example below:
39
40--------
41 [section "subsection"]
42
43--------
44
45Subsection names are case sensitive and can contain any characters except
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
49`t` and `\0` is read as `0` Section headers cannot span multiple lines.
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.
53
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.
58
59All the other lines (and the remainder of the line after the section
60header) are recognized as setting variables, in the form
61'name = value' (or just 'name', which is a short-hand to say that
62the variable is the boolean "true").
63The variable names are case-insensitive, allow only alphanumeric characters
64and `-`, and must start with an alphabetic character.
65
66A line that defines a value can be continued to the next line by
67ending it with a `\`; the backslash and the end-of-line are
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.
73
74Inside double quotes, double quote `"` and backslash `\` characters
75must be escaped: use `\"` for `"` and `\\` for `\`.
76
77The following escape sequences (beside `\"` and `\\`) are recognized:
78`\n` for newline character (NL), `\t` for horizontal tabulation (HT, TAB)
79and `\b` for backspace (BS). Other char escape sequences (including octal
80escape sequences) are invalid.
81
82
83Includes
84~~~~~~~~
85
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
92You can include a config file from another by setting the special
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.
96
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
99variable is a relative path, the path is considered to
100be relative to the configuration file in which the include directive
101was found. See below for examples.
102
103Conditional includes
104~~~~~~~~~~~~~~~~~~~~
105
106You can include a config file from another conditionally by setting a
107`includeIf.<condition>.path` variable to the name of the file to be
108included.
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`
121environment variable. If the repository is auto discovered via a .git
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
146 case-insensitively (e.g. on case-insensitive file systems)
147
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
162A few more notes on matching via `gitdir` and `gitdir/i`:
163
164 * Symlinks in `$GIT_DIR` are not resolved before matching.
165
166 * Both the symlink & realpath versions of paths will be matched
167 outside of `$GIT_DIR`. E.g. if ~/git is a symlink to
168 /mnt/storage/git, both `gitdir:~/git` and `gitdir:/mnt/storage/git`
169 will match.
170+
171This was not the case in the initial release of this feature in
172v2.13.0, which only matched the realpath version. Configuration that
173wants to be compatible with the initial release of this feature needs
174to either specify only the realpath version, or both versions.
175
176 * Note that "../" is not special and will match literally, which is
177 unlikely what you want.
178
179Example
180~~~~~~~
181
182----
183# Core variables
184[core]
185 ; Don't trust file modes
186 filemode = false
187
188# Our diff algorithm
189[diff]
190 external = /usr/local/bin/diff-wrapper
191 renames = true
192
193[branch "devel"]
194 remote = origin
195 merge = refs/heads/devel
196
197# Proxy settings
198[core]
199 gitProxy="ssh" for "kernel.org"
200 gitProxy=default-proxy ; for the rest
201
202[include]
203 path = /path/to/foo.inc ; include by absolute path
204 path = foo.inc ; find "foo.inc" relative to the current file
205 path = ~/foo.inc ; find "foo.inc" in your `$HOME` directory
206
207; include if $GIT_DIR is /path/to/foo/.git
208[includeIf "gitdir:/path/to/foo/.git"]
209 path = /path/to/foo.inc
210
211; include for all repositories inside /path/to/group
212[includeIf "gitdir:/path/to/group/"]
213 path = /path/to/foo.inc
214
215; include for all repositories inside $HOME/to/group
216[includeIf "gitdir:~/to/group/"]
217 path = /path/to/foo.inc
218
219; relative paths are always relative to the including
220; file (if the condition is true); their location is not
221; affected by the condition
222[includeIf "gitdir:/path/to/group/"]
223 path = foo.inc
224
225; include only if we are in a worktree where foo-branch is
226; currently checked out
227[includeIf "onbranch:foo-branch"]
228 path = foo.inc
229----
230
231Values
232~~~~~~
233
234Values of many variables are treated as a simple string, but there
235are variables that take values of specific types and there are rules
236as to how to spell them.
237
238boolean::
239
240 When a variable is said to take a boolean value, many
241 synonyms are accepted for 'true' and 'false'; these are all
242 case-insensitive.
243
244 true;; Boolean true literals are `yes`, `on`, `true`,
245 and `1`. Also, a variable defined without `= <value>`
246 is taken as true.
247
248 false;; Boolean false literals are `no`, `off`, `false`,
249 `0` and the empty string.
250+
251When converting a value to its canonical form using the `--type=bool` type
252specifier, 'git config' will ensure that the output is "true" or
253"false" (spelled in lowercase).
254
255integer::
256 The value for many variables that specify various sizes can
257 be suffixed with `k`, `M`,... to mean "scale the number by
258 1024", "by 1024x1024", etc.
259
260color::
261 The value for a variable that takes a color is a list of
262 colors (at most two, one for foreground and one for background)
263 and attributes (as many as you want), separated by spaces.
264+
265The basic colors accepted are `normal`, `black`, `red`, `green`, `yellow`,
266`blue`, `magenta`, `cyan` and `white`. The first color given is the
267foreground; the second is the background. All the basic colors except
268`normal` have a bright variant that can be specified by prefixing the
269color with `bright`, like `brightred`.
270+
271Colors may also be given as numbers between 0 and 255; these use ANSI
272256-color mode (but note that not all terminals may support this). If
273your terminal supports it, you may also specify 24-bit RGB values as
274hex, like `#ff0ab3`.
275+
276The accepted attributes are `bold`, `dim`, `ul`, `blink`, `reverse`,
277`italic`, and `strike` (for crossed-out or "strikethrough" letters).
278The position of any attributes with respect to the colors
279(before, after, or in between), doesn't matter. Specific attributes may
280be turned off by prefixing them with `no` or `no-` (e.g., `noreverse`,
281`no-ul`, etc).
282+
283An empty color string produces no color effect at all. This can be used
284to avoid coloring specific elements without disabling color entirely.
285+
286For git's pre-defined color slots, the attributes are meant to be reset
287at the beginning of each item in the colored output. So setting
288`color.decorate.branch` to `black` will paint that branch name in a
289plain `black`, even if the previous thing on the same output line (e.g.
290opening parenthesis before the list of branch names in `log --decorate`
291output) is set to be painted with `bold` or some other attribute.
292However, custom log formats may do more complicated and layered
293coloring, and the negated forms may be useful there.
294
295pathname::
296 A variable that takes a pathname value can be given a
297 string that begins with "`~/`" or "`~user/`", and the usual
298 tilde expansion happens to such a string: `~/`
299 is expanded to the value of `$HOME`, and `~user/` to the
300 specified user's home directory.
301
302
303Variables
304~~~~~~~~~
305
306Note that this list is non-comprehensive and not necessarily complete.
307For command-specific variables, you will find a more detailed description
308in the appropriate manual page.
309
310Other git-related tools may and do use their own variables. When
311inventing new variables for use in your own tool, make sure their
312names do not conflict with those that are used by Git itself and
313other popular tools, and describe them in your documentation.
314
315include::config/advice.txt[]
316
317include::config/core.txt[]
318
319include::config/add.txt[]
320
321include::config/alias.txt[]
322
323include::config/am.txt[]
324
325include::config/apply.txt[]
326
327include::config/blame.txt[]
328
329include::config/branch.txt[]
330
331include::config/browser.txt[]
332
333include::config/checkout.txt[]
334
335include::config/clean.txt[]
336
337include::config/clone.txt[]
338
339include::config/color.txt[]
340
341include::config/column.txt[]
342
343include::config/commit.txt[]
344
345include::config/commitgraph.txt[]
346
347include::config/credential.txt[]
348
349include::config/completion.txt[]
350
351include::config/diff.txt[]
352
353include::config/difftool.txt[]
354
355include::config/extensions.txt[]
356
357include::config/fastimport.txt[]
358
359include::config/feature.txt[]
360
361include::config/fetch.txt[]
362
363include::config/format.txt[]
364
365include::config/filter.txt[]
366
367include::config/fsck.txt[]
368
369include::config/gc.txt[]
370
371include::config/gitcvs.txt[]
372
373include::config/gitweb.txt[]
374
375include::config/grep.txt[]
376
377include::config/gpg.txt[]
378
379include::config/gui.txt[]
380
381include::config/guitool.txt[]
382
383include::config/help.txt[]
384
385include::config/http.txt[]
386
387include::config/i18n.txt[]
388
389include::config/imap.txt[]
390
391include::config/index.txt[]
392
393include::config/init.txt[]
394
395include::config/instaweb.txt[]
396
397include::config/interactive.txt[]
398
399include::config/log.txt[]
400
401include::config/mailinfo.txt[]
402
403include::config/mailmap.txt[]
404
405include::config/maintenance.txt[]
406
407include::config/man.txt[]
408
409include::config/merge.txt[]
410
411include::config/mergetool.txt[]
412
413include::config/notes.txt[]
414
415include::config/pack.txt[]
416
417include::config/pager.txt[]
418
419include::config/pretty.txt[]
420
421include::config/protocol.txt[]
422
423include::config/pull.txt[]
424
425include::config/push.txt[]
426
427include::config/rebase.txt[]
428
429include::config/receive.txt[]
430
431include::config/remote.txt[]
432
433include::config/remotes.txt[]
434
435include::config/repack.txt[]
436
437include::config/rerere.txt[]
438
439include::config/reset.txt[]
440
441include::config/sendemail.txt[]
442
443include::config/sequencer.txt[]
444
445include::config/showbranch.txt[]
446
447include::config/splitindex.txt[]
448
449include::config/ssh.txt[]
450
451include::config/status.txt[]
452
453include::config/stash.txt[]
454
455include::config/submodule.txt[]
456
457include::config/tag.txt[]
458
459include::config/tar.txt[]
460
461include::config/trace2.txt[]
462
463include::config/transfer.txt[]
464
465include::config/uploadarchive.txt[]
466
467include::config/uploadpack.txt[]
468
469include::config/url.txt[]
470
471include::config/user.txt[]
472
473include::config/versionsort.txt[]
474
475include::config/web.txt[]
476
477include::config/worktree.txt[]