interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / Documentation / config.adoc

635 lines · 21667 bytes Raw Blame History
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 porcelain commands. 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. 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.
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
32section begins. Section names are case-insensitive. Only alphanumeric
33characters, `-` and `.` are allowed in section names. Each variable
34must belong to some section, which means that there must be a section
35header before the first setting of a variable.
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,
39in the section header, like in the example below:
40
41--------
42 [section "subsection"]
43
44--------
45
46Subsection names are case sensitive and can contain any characters except
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
50`t` and `\0` is read as `0`. Section headers cannot span multiple lines.
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.
54
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.
59
60All the other lines (and the remainder of the line after the section
61header) are recognized as setting variables, in the form
62'name = value' (or just 'name', which is a short-hand to say that
63the variable is the boolean "true").
64The variable names are case-insensitive, allow only alphanumeric characters
65and `-`, and must start with an alphabetic character.
66
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.
73
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 `\`.
78
79The following escape sequences (beside `\"` and `\\`) are recognized:
80`\n` for newline character (NL), `\t` for horizontal tabulation (HT, TAB)
81and `\b` for backspace (BS). Other char escape sequences (including octal
82escape sequences) are invalid.
83
84
85Includes
86~~~~~~~~
87
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
94You can include a config file from another by setting the special
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.
98
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
101variable is a relative path, the path is considered to
102be relative to the configuration file in which the include directive
103was found. See below for examples.
104
105Conditional includes
106~~~~~~~~~~~~~~~~~~~~
107
108You can conditionally include a config file from another by setting an
109`includeIf.<condition>.path` variable to the name of the file to be
110included.
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 The data that follows the keyword `gitdir` and a colon is used as a glob
118 pattern. If the location of the .git directory matches the
119 pattern, the include condition is met.
120+
121The .git location may be auto-discovered, or come from `$GIT_DIR`
122environment variable. If the repository is auto-discovered via a .git
123file (e.g. from submodules, or a linked worktree), the .git location
124would be the final location where the .git directory is, not where the
125.git file is.
126+
127The pattern can contain standard globbing wildcards and two additional
128ones, `**/` and `/**`, that can match multiple path components. Please
129refer to linkgit:gitignore[5] for details. For convenience:
130
131 * If the pattern starts with `~/`, `~` will be substituted with the
132 content of the environment variable `HOME`.
133
134 * If the pattern starts with `./`, it is replaced with the directory
135 containing the current config file.
136
137 * If the pattern does not start with either `~/`, `./` or `/`, `**/`
138 will be automatically prepended. For example, the pattern `foo/bar`
139 becomes `**/foo/bar` and would match `/any/path/to/foo/bar`.
140
141 * If the pattern ends with `/`, `**` will be automatically added. For
142 example, the pattern `foo/` becomes `foo/**`. In other words, it
143 matches "foo" and everything inside, recursively.
144
145`gitdir/i`::
146 This is the same as `gitdir` except that matching is done
147 case-insensitively (e.g. on case-insensitive file systems)
148
149`worktree`::
150 The data that follows the keyword `worktree` and a colon is used as a
151 glob pattern. If the working directory of the current worktree matches
152 the pattern, the include condition is met.
153+
154The worktree location is the path where files are checked out (as returned
155by `git rev-parse --show-toplevel`). This is different from `gitdir`, which
156matches the `.git` directory path. In a linked worktree, the worktree path
157is the directory where that worktree's files are located, not the main
158repository's `.git` directory.
159+
160The pattern uses the same glob syntax as `gitdir` (including `~/`, `./`,
161`**/`, and trailing-`/` prefix matching). This condition will never match
162in a bare repository (which has no worktree).
163+
164Unlike `gitdir`, the `worktree` condition currently matches only the
165realpath-resolved worktree location. If the working tree was entered via a
166symbolic link, a pattern that uses the symbolic-link spelling may not match;
167use the real path instead.
168+
169This is useful when you want to apply configuration based on where the
170working tree is located on the filesystem. For example, a contributor who
171works on the same project both personally and as an employee can use
172different `user.name` and `user.email` values depending on which directory
173the worktree is checked out under:
174+
175----
176[includeIf "worktree:/home/user/work/"]
177 path = ~/.config/git/work.inc
178[includeIf "worktree:/home/user/personal/"]
179 path = ~/.config/git/personal.inc
180----
181+
182While `extensions.worktreeConfig` (see linkgit:git-worktree[1]) also supports
183per-worktree configuration, it stores the config inside each repository's
184`.git/config.worktree` file and requires running `git config --worktree`
185inside each worktree individually. In contrast, `includeIf "worktree:..."`
186can be set once in a global or system-level configuration file (e.g.
187`~/.config/git/config`) and applies to all repositories at once based on
188their worktree location.
189
190`worktree/i`::
191 This is the same as `worktree` except that matching is done
192 case-insensitively (e.g. on case-insensitive file systems)
193
194`onbranch`::
195 The data that follows the keyword `onbranch` and a colon is taken to be a
196 pattern with standard globbing wildcards and two additional
197 ones, `**/` and `/**`, that can match multiple path components.
198 If we are in a worktree where the name of the branch that is
199 currently checked out matches the pattern, the include condition
200 is met.
201+
202If the pattern ends with `/`, `**` will be automatically added. For
203example, the pattern `foo/` becomes `foo/**`. In other words, it matches
204all branches that begin with `foo/`. This is useful if your branches are
205organized hierarchically and you would like to apply a configuration to
206all the branches in that hierarchy.
207
208`hasconfig:remote.*.url`::
209 The data that follows this keyword and a colon is taken to
210 be a pattern with standard globbing wildcards and two
211 additional ones, `**/` and `/**`, that can match multiple
212 components. The first time this keyword is seen, the rest of
213 the config files will be scanned for remote URLs (without
214 applying any values). If there exists at least one remote URL
215 that matches this pattern, the include condition is met.
216+
217Files included by this option (directly or indirectly) are not allowed
218to contain remote URLs.
219+
220Note that unlike other includeIf conditions, resolving this condition
221relies on information that is not yet known at the point of reading the
222condition. A typical use case is this option being present as a
223system-level or global-level config, and the remote URL being in a
224local-level config; hence the need to scan ahead when resolving this
225condition. In order to avoid the chicken-and-egg problem in which
226potentially-included files can affect whether such files are potentially
227included, Git breaks the cycle by prohibiting these files from affecting
228the resolution of these conditions (thus, prohibiting them from
229declaring remote URLs).
230+
231As for the naming of this keyword, it is for forwards compatibility with
232a naming scheme that supports more variable-based include conditions,
233but currently Git only supports the exact keyword described above.
234
235`hostname`::
236 The data that follows the keyword `hostname:` is taken to be a
237 pattern with standard globbing wildcards. If the hostname of
238 the machine matches the pattern, the include condition is met.
239+
240Depending on how your system is configured, the hostname used for
241matching may be short (e.g., "myhost") or a fully qualified domain
242name ("myhost.example.com"). Run `git var GIT_HOSTNAME` to see the
243hostname Git uses (see linkgit:git-var[1]).
244
245A few more notes on matching via `gitdir` and `gitdir/i`:
246
247 * Symlinks in `$GIT_DIR` are not resolved before matching.
248
249 * Both the symlink & realpath versions of paths will be matched
250 outside of `$GIT_DIR`. E.g. if ~/git is a symlink to
251 /mnt/storage/git, both `gitdir:~/git` and `gitdir:/mnt/storage/git`
252 will match.
253+
254This was not the case in the initial release of this feature in
255v2.13.0, which only matched the realpath version. Configuration that
256wants to be compatible with the initial release of this feature needs
257to either specify only the realpath version, or both versions.
258
259 * Note that "../" is not special and will match literally, which is
260 unlikely what you want.
261
262Example
263~~~~~~~
264
265----
266# Core variables
267[core]
268 ; Don't trust file modes
269 filemode = false
270
271# Our diff algorithm
272[diff]
273 external = /usr/local/bin/diff-wrapper
274 renames = true
275
276[branch "devel"]
277 remote = origin
278 merge = refs/heads/devel
279
280# Proxy settings
281[core]
282 gitProxy="ssh" for "kernel.org"
283 gitProxy=default-proxy ; for the rest
284
285[include]
286 path = /path/to/foo.inc ; include by absolute path
287 path = foo.inc ; find "foo.inc" relative to the current file
288 path = ~/foo.inc ; find "foo.inc" in your `$HOME` directory
289
290; include if $GIT_DIR is /path/to/foo/.git
291[includeIf "gitdir:/path/to/foo/.git"]
292 path = /path/to/foo.inc
293
294; include for all repositories inside /path/to/group
295[includeIf "gitdir:/path/to/group/"]
296 path = /path/to/foo.inc
297
298; include for all repositories inside $HOME/to/group
299[includeIf "gitdir:~/to/group/"]
300 path = /path/to/foo.inc
301
302; include if the worktree is at /path/to/project-build
303[includeIf "worktree:/path/to/project-build"]
304 path = build-config.inc
305
306; include for all worktrees inside /path/to/group
307[includeIf "worktree:/path/to/group/"]
308 path = group-config.inc
309
310; relative paths are always relative to the including
311; file (if the condition is true); their location is not
312; affected by the condition
313[includeIf "gitdir:/path/to/group/"]
314 path = foo.inc
315
316; include only if we are in a worktree where foo-branch is
317; currently checked out
318[includeIf "onbranch:foo-branch"]
319 path = foo.inc
320
321; include only if a remote with the given URL exists (note
322; that such a URL may be provided later in a file or in a
323; file read after this file is read, as seen in this example)
324[includeIf "hasconfig:remote.*.url:https://example.com/**"]
325 path = foo.inc
326[remote "origin"]
327 url = https://example.com/git
328
329; include only if the hostname of the machine matches some-hostname
330[includeIf "hostname:some-hostname"]
331 path = foo.inc
332----
333
334Values
335~~~~~~
336
337Values of many variables are treated as a simple string, but there
338are variables that take values of specific types and there are rules
339as to how to spell them.
340
341boolean::
342
343 When a variable is said to take a boolean value, many
344 synonyms are accepted for 'true' and 'false'; these are all
345 case-insensitive.
346+
347--
348 true;; Boolean true literals are `yes`, `on`, `true`,
349 and `1`. Also, a variable defined without `= <value>`
350 is taken as true.
351
352 false;; Boolean false literals are `no`, `off`, `false`,
353 `0` and the empty string.
354--
355+
356When converting a value to its canonical form using the `--type=bool` type
357specifier, 'git config' will ensure that the output is "true" or
358"false" (spelled in lowercase).
359
360integer::
361 The value for many variables that specify various sizes can
362 be suffixed with `k`, `M`,... to mean "scale the number by
363 1024", "by 1024x1024", etc.
364
365color::
366 The value for a variable that takes a color is a list of
367 colors (at most two, one for foreground and one for background)
368 and attributes (as many as you want), separated by spaces.
369+
370The basic colors accepted are `normal`, `black`, `red`, `green`,
371`yellow`, `blue`, `magenta`, `cyan`, `white` and `default`. The first
372color given is the foreground; the second is the background. All the
373basic colors except `normal` and `default` have a bright variant that can
374be specified by prefixing the color with `bright`, like `brightred`.
375+
376The color `normal` makes no change to the color. It is the same as an
377empty string, but can be used as the foreground color when specifying a
378background color alone (for example, "normal red").
379+
380The color `default` explicitly resets the color to the terminal default,
381for example to specify a cleared background. Although it varies between
382terminals, this is usually not the same as setting to "white black".
383+
384Colors may also be given as numbers between 0 and 255; these use ANSI
385256-color mode (but note that not all terminals may support this). If
386your terminal supports it, you may also specify 24-bit RGB values as
387hex, like `#ff0ab3`, or 12-bit RGB values like `#f1b`, which is
388equivalent to the 24-bit color `#ff11bb`.
389+
390The accepted attributes are `bold`, `dim`, `ul`, `blink`, `reverse`,
391`italic`, and `strike` (for crossed-out or "strikethrough" letters).
392The position of any attributes with respect to the colors
393(before, after, or in between), doesn't matter. Specific attributes may
394be turned off by prefixing them with `no` or `no-` (e.g., `noreverse`,
395`no-ul`, etc).
396+
397The pseudo-attribute `reset` resets all colors and attributes before
398applying the specified coloring. For example, `reset green` will result
399in a green foreground and default background without any active
400attributes.
401+
402An empty color string produces no color effect at all. This can be used
403to avoid coloring specific elements without disabling color entirely.
404+
405For git's pre-defined color slots, the attributes are meant to be reset
406at the beginning of each item in the colored output. So setting
407`color.decorate.branch` to `black` will paint that branch name in a
408plain `black`, even if the previous thing on the same output line (e.g.
409opening parenthesis before the list of branch names in `log --decorate`
410output) is set to be painted with `bold` or some other attribute.
411However, custom log formats may do more complicated and layered
412coloring, and the negated forms may be useful there.
413
414pathname::
415 A variable that takes a pathname value can be given a
416 string that begins with "`~/`" or "`~user/`", and the usual
417 tilde expansion happens to such a string: `~/`
418 is expanded to the value of `$HOME`, and `~user/` to the
419 specified user's home directory.
420+
421If a path starts with `%(prefix)/`, the remainder is interpreted as a
422path relative to Git's "runtime prefix", i.e. relative to the location
423where Git itself was installed. For example, `%(prefix)/bin/` refers to
424the directory in which the Git executable itself lives. If Git was
425compiled without runtime prefix support, the compiled-in prefix will be
426substituted instead. In the unlikely event that a literal path needs to
427be specified that should _not_ be expanded, it needs to be prefixed by
428`./`, like so: `./%(prefix)/bin`.
429+
430If prefixed with `:(optional)`, the configuration variable is treated
431as if it does not exist, if the named path does not exist.
432
433Variables
434~~~~~~~~~
435
436Note that this list is non-comprehensive and not necessarily complete.
437For command-specific variables, you will find a more detailed description
438in the appropriate manual page.
439
440Other git-related tools may and do use their own variables. When
441inventing new variables for use in your own tool, make sure their
442names do not conflict with those that are used by Git itself and
443other popular tools, and describe them in your documentation.
444
445include::config/add.adoc[]
446
447include::config/advice.adoc[]
448
449include::config/alias.adoc[]
450
451include::config/am.adoc[]
452
453include::config/apply.adoc[]
454
455include::config/attr.adoc[]
456
457include::config/bitmap-pseudo-merge.adoc[]
458
459include::config/blame.adoc[]
460
461include::config/branch.adoc[]
462
463include::config/browser.adoc[]
464
465include::config/bundle.adoc[]
466
467include::config/checkout.adoc[]
468
469include::config/clean.adoc[]
470
471include::config/clone.adoc[]
472
473include::config/color.adoc[]
474
475include::config/column.adoc[]
476
477include::config/commit.adoc[]
478
479include::config/commitgraph.adoc[]
480
481include::config/completion.adoc[]
482
483include::config/core.adoc[]
484
485include::config/credential.adoc[]
486
487include::config/diff.adoc[]
488
489include::config/difftool.adoc[]
490
491include::config/extensions.adoc[]
492
493include::config/fastimport.adoc[]
494
495include::config/feature.adoc[]
496
497include::config/fetch.adoc[]
498
499include::config/filter.adoc[]
500
501include::config/format.adoc[]
502
503include::config/fsck.adoc[]
504
505include::config/fsmonitor--daemon.adoc[]
506
507include::config/gc.adoc[]
508
509include::config/gitcvs.adoc[]
510
511include::config/gitweb.adoc[]
512
513include::config/gpg.adoc[]
514
515include::config/grep.adoc[]
516
517include::config/gui.adoc[]
518
519include::config/guitool.adoc[]
520
521include::config/help.adoc[]
522
523include::config/hook.adoc[]
524
525include::config/http.adoc[]
526
527include::config/i18n.adoc[]
528
529include::config/imap.adoc[]
530
531include::config/includeif.adoc[]
532
533include::config/index.adoc[]
534
535include::config/init.adoc[]
536
537include::config/instaweb.adoc[]
538
539include::config/interactive.adoc[]
540
541include::config/log.adoc[]
542
543include::config/lsrefs.adoc[]
544
545include::config/mailinfo.adoc[]
546
547include::config/mailmap.adoc[]
548
549include::config/maintenance.adoc[]
550
551include::config/man.adoc[]
552
553include::config/merge.adoc[]
554
555include::config/mergetool.adoc[]
556
557include::config/notes.adoc[]
558
559include::config/pack.adoc[]
560
561include::config/pager.adoc[]
562
563include::config/pretty.adoc[]
564
565include::config/promisor.adoc[]
566
567include::config/protocol.adoc[]
568
569include::config/pull.adoc[]
570
571include::config/push.adoc[]
572
573include::config/rebase.adoc[]
574
575include::config/receive.adoc[]
576
577include::config/reftable.adoc[]
578
579include::config/remote.adoc[]
580
581include::config/remotes.adoc[]
582
583include::config/repack.adoc[]
584
585include::config/replay.adoc[]
586
587include::config/rerere.adoc[]
588
589include::config/revert.adoc[]
590
591include::config/safe.adoc[]
592
593include::config/sendemail.adoc[]
594
595include::config/sequencer.adoc[]
596
597include::config/showbranch.adoc[]
598
599include::config/sideband.adoc[]
600
601include::config/sparse.adoc[]
602
603include::config/splitindex.adoc[]
604
605include::config/ssh.adoc[]
606
607include::config/stash.adoc[]
608
609include::config/status.adoc[]
610
611include::config/submodule.adoc[]
612
613include::config/tag.adoc[]
614
615include::config/tar.adoc[]
616
617include::config/trace2.adoc[]
618
619include::config/trailer.adoc[]
620
621include::config/transfer.adoc[]
622
623include::config/uploadarchive.adoc[]
624
625include::config/uploadpack.adoc[]
626
627include::config/url.adoc[]
628
629include::config/user.adoc[]
630
631include::config/versionsort.adoc[]
632
633include::config/web.adoc[]
634
635include::config/worktree.adoc[]