4 The Git configuration file contains a number of variables that affect
5 the Git commands' behavior. The files `.git/config` and optionally
6 `config.worktree` (see the "CONFIGURATION FILE" section of
7 linkgit:git-worktree[1]) in each repository are used to store the
8 configuration for that repository, and `$HOME/.gitconfig` is used to
9 store a per-user configuration as fallback values for the `.git/config`
10 file. The file `/etc/gitconfig` can be used to store a system-wide
11 default configuration.
13 The configuration variables are used by both the Git plumbing
14 and the porcelain commands. The variables are divided into sections, wherein
15 the fully qualified variable name of the variable itself is the last
16 dot-separated segment and the section name is everything before the last
17 dot. The variable names are case-insensitive, allow only alphanumeric
18 characters and `-`, and must start with an alphabetic character. Some
19 variables may appear multiple times; we say then that the variable is
25 The syntax is fairly flexible and permissive. Whitespace characters,
26 which in this context are the space character (SP) and the horizontal
27 tabulation (HT), are mostly ignored. The '#' and ';' characters begin
28 comments to the end of line. Blank lines are ignored.
30 The file consists of sections and variables. A section begins with
31 the name of the section in square brackets and continues until the next
32 section begins. Section names are case-insensitive. Only alphanumeric
33 characters, `-` and `.` are allowed in section names. Each variable
34 must belong to some section, which means that there must be a section
35 header before the first setting of a variable.
37 Sections can be further divided into subsections. To begin a subsection
38 put its name in double quotes, separated by space from the section name,
39 in the section header, like in the example below:
42 [section "subsection"]
46 Subsection names are case sensitive and can contain any characters except
47 newline and the null byte. Doublequote `"` and backslash can be included
48 by escaping them as `\"` and `\\`, respectively. Backslashes preceding
49 other 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.
51 Variables may belong directly to a section or to a given subsection. You
52 can have `[section]` if you have `[section "subsection"]`, but you don't
55 There is also a deprecated `[section.subsection]` syntax. With this
56 syntax, the subsection name is converted to lower-case and is also
57 compared case sensitively. These subsection names follow the same
58 restrictions as section names.
60 All the other lines (and the remainder of the line after the section
61 header) are recognized as setting variables, in the form
62 'name = value' (or just 'name', which is a short-hand to say that
63 the variable is the boolean "true").
64 The variable names are case-insensitive, allow only alphanumeric characters
65 and `-`, and must start with an alphabetic character.
67 Whitespace characters surrounding `name`, `=` and `value` are discarded.
68 Internal whitespace characters within 'value' are retained verbatim.
69 Comments starting with either `#` or `;` and extending to the end of line
70 are discarded. A line that defines a value can be continued to the next
71 line by ending it with a backslash (`\`); the backslash and the end-of-line
72 characters are discarded.
74 If `value` needs to contain leading or trailing whitespace characters,
75 it must be enclosed in double quotation marks (`"`). Inside double quotation
76 marks, double quote (`"`) and backslash (`\`) characters must be escaped:
77 use `\"` for `"` and `\\` for `\`.
79 The following escape sequences (beside `\"` and `\\`) are recognized:
80 `\n` for newline character (NL), `\t` for horizontal tabulation (HT, TAB)
81 and `\b` for backspace (BS). Other char escape sequences (including octal
82 escape sequences) are invalid.
88 The `include` and `includeIf` sections allow you to include config
89 directives from another source. These sections behave identically to
90 each other with the exception that `includeIf` sections may be ignored
91 if their condition does not evaluate to true; see "Conditional includes"
94 You can include a config file from another by setting the special
95 `include.path` (or `includeIf.*.path`) variable to the name of the file
96 to be included. The variable takes a pathname as its value, and is
97 subject to tilde expansion. These variables can be given multiple times.
99 The contents of the included file are inserted immediately, as if they
100 had been found at the location of the include directive. If the value of the
101 variable is a relative path, the path is considered to
102 be relative to the configuration file in which the include directive
103 was found. See below for examples.
108 You can conditionally include a config file from another by setting an
109 `includeIf.<condition>.path` variable to the name of the file to be
112 The condition starts with a keyword followed by a colon and some data
113 whose format and meaning depends on the keyword. Supported keywords
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.
122 The .git location may be auto-discovered, or come from `$GIT_DIR`
123 environment variable. If the repository is auto-discovered via a .git
124 file (e.g. from submodules, or a linked worktree), the .git location
125 would be the final location where the .git directory is, not where the
128 The pattern can contain standard globbing wildcards and two additional
129 ones, `**/` and `/**`, that can match multiple path components. Please
130 refer to linkgit:gitignore[5] for details. For convenience:
132 * If the pattern starts with `~/`, `~` will be substituted with the
133 content of the environment variable `HOME`.
135 * If the pattern starts with `./`, it is replaced with the directory
136 containing the current config file.
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`.
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.
147 This is the same as `gitdir` except that matching is done
148 case-insensitively (e.g. on case-insensitive file systems)
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
158 If the pattern ends with `/`, `**` will be automatically added. For
159 example, the pattern `foo/` becomes `foo/**`. In other words, it matches
160 all branches that begin with `foo/`. This is useful if your branches are
161 organized hierarchically and you would like to apply a configuration to
162 all the branches in that hierarchy.
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.
173 Files included by this option (directly or indirectly) are not allowed
174 to contain remote URLs.
176 Note that unlike other includeIf conditions, resolving this condition
177 relies on information that is not yet known at the point of reading the
178 condition. A typical use case is this option being present as a
179 system-level or global-level config, and the remote URL being in a
180 local-level config; hence the need to scan ahead when resolving this
181 condition. In order to avoid the chicken-and-egg problem in which
182 potentially-included files can affect whether such files are potentially
183 included, Git breaks the cycle by prohibiting these files from affecting
184 the resolution of these conditions (thus, prohibiting them from
185 declaring remote URLs).
187 As for the naming of this keyword, it is for forwards compatibility with
188 a naming scheme that supports more variable-based include conditions,
189 but currently Git only supports the exact keyword described above.
191 A few more notes on matching via `gitdir` and `gitdir/i`:
193 * Symlinks in `$GIT_DIR` are not resolved before matching.
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`
200 This was not the case in the initial release of this feature in
201 v2.13.0, which only matched the realpath version. Configuration that
202 wants to be compatible with the initial release of this feature needs
203 to either specify only the realpath version, or both versions.
205 * Note that "../" is not special and will match literally, which is
206 unlikely what you want.
214 ; Don't trust file modes
219 external = /usr/local/bin/diff-wrapper
224 merge = refs/heads/devel
228 gitProxy="ssh" for "kernel.org"
229 gitProxy=default-proxy ; for the rest
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
236 ; include if $GIT_DIR is /path/to/foo/.git
237 [includeIf "gitdir:/path/to/foo/.git"]
238 path = /path/to/foo.inc
240 ; include for all repositories inside /path/to/group
241 [includeIf "gitdir:/path/to/group/"]
242 path = /path/to/foo.inc
244 ; include for all repositories inside $HOME/to/group
245 [includeIf "gitdir:~/to/group/"]
246 path = /path/to/foo.inc
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/"]
254 ; include only if we are in a worktree where foo-branch is
255 ; currently checked out
256 [includeIf "onbranch:foo-branch"]
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/**"]
265 url = https://example.com/git
271 Values of many variables are treated as a simple string, but there
272 are variables that take values of specific types and there are rules
273 as to how to spell them.
277 When a variable is said to take a boolean value, many
278 synonyms are accepted for 'true' and 'false'; these are all
281 true;; Boolean true literals are `yes`, `on`, `true`,
282 and `1`. Also, a variable defined without `= <value>`
285 false;; Boolean false literals are `no`, `off`, `false`,
286 `0` and the empty string.
288 When converting a value to its canonical form using the `--type=bool` type
289 specifier, 'git config' will ensure that the output is "true" or
290 "false" (spelled in lowercase).
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.
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.
302 The basic colors accepted are `normal`, `black`, `red`, `green`,
303 `yellow`, `blue`, `magenta`, `cyan`, `white` and `default`. The first
304 color given is the foreground; the second is the background. All the
305 basic colors except `normal` and `default` have a bright variant that can
306 be specified by prefixing the color with `bright`, like `brightred`.
308 The color `normal` makes no change to the color. It is the same as an
309 empty string, but can be used as the foreground color when specifying a
310 background color alone (for example, "normal red").
312 The color `default` explicitly resets the color to the terminal default,
313 for example to specify a cleared background. Although it varies between
314 terminals, this is usually not the same as setting to "white black".
316 Colors may also be given as numbers between 0 and 255; these use ANSI
317 256-color mode (but note that not all terminals may support this). If
318 your terminal supports it, you may also specify 24-bit RGB values as
319 hex, like `#ff0ab3`, or 12-bit RGB values like `#f1b`, which is
320 equivalent to the 24-bit color `#ff11bb`.
322 The accepted attributes are `bold`, `dim`, `ul`, `blink`, `reverse`,
323 `italic`, and `strike` (for crossed-out or "strikethrough" letters).
324 The position of any attributes with respect to the colors
325 (before, after, or in between), doesn't matter. Specific attributes may
326 be turned off by prefixing them with `no` or `no-` (e.g., `noreverse`,
329 The pseudo-attribute `reset` resets all colors and attributes before
330 applying the specified coloring. For example, `reset green` will result
331 in a green foreground and default background without any active
334 An empty color string produces no color effect at all. This can be used
335 to avoid coloring specific elements without disabling color entirely.
337 For git's pre-defined color slots, the attributes are meant to be reset
338 at the beginning of each item in the colored output. So setting
339 `color.decorate.branch` to `black` will paint that branch name in a
340 plain `black`, even if the previous thing on the same output line (e.g.
341 opening parenthesis before the list of branch names in `log --decorate`
342 output) is set to be painted with `bold` or some other attribute.
343 However, custom log formats may do more complicated and layered
344 coloring, and the negated forms may be useful there.
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.
353 If a path starts with `%(prefix)/`, the remainder is interpreted as a
354 path relative to Git's "runtime prefix", i.e. relative to the location
355 where Git itself was installed. For example, `%(prefix)/bin/` refers to
356 the directory in which the Git executable itself lives. If Git was
357 compiled without runtime prefix support, the compiled-in prefix will be
358 substituted instead. In the unlikely event that a literal path needs to
359 be specified that should _not_ be expanded, it needs to be prefixed by
360 `./`, like so: `./%(prefix)/bin`.
366 Note that this list is non-comprehensive and not necessarily complete.
367 For command-specific variables, you will find a more detailed description
368 in the appropriate manual page.
370 Other git-related tools may and do use their own variables. When
371 inventing new variables for use in your own tool, make sure their
372 names do not conflict with those that are used by Git itself and
373 other popular tools, and describe them in your documentation.
375 include::config/add.txt[]
377 include::config/advice.txt[]
379 include::config/alias.txt[]
381 include::config/am.txt[]
383 include::config/apply.txt[]
385 include::config/attr.txt[]
387 include::config/bitmap-pseudo-merge.txt[]
389 include::config/blame.txt[]
391 include::config/branch.txt[]
393 include::config/browser.txt[]
395 include::config/bundle.txt[]
397 include::config/checkout.txt[]
399 include::config/clean.txt[]
401 include::config/clone.txt[]
403 include::config/color.txt[]
405 include::config/column.txt[]
407 include::config/commit.txt[]
409 include::config/commitgraph.txt[]
411 include::config/completion.txt[]
413 include::config/core.txt[]
415 include::config/credential.txt[]
417 include::config/diff.txt[]
419 include::config/difftool.txt[]
421 include::config/extensions.txt[]
423 include::config/fastimport.txt[]
425 include::config/feature.txt[]
427 include::config/fetch.txt[]
429 include::config/filter.txt[]
431 include::config/format.txt[]
433 include::config/fsck.txt[]
435 include::config/fsmonitor--daemon.txt[]
437 include::config/gc.txt[]
439 include::config/gitcvs.txt[]
441 include::config/gitweb.txt[]
443 include::config/gpg.txt[]
445 include::config/grep.txt[]
447 include::config/gui.txt[]
449 include::config/guitool.txt[]
451 include::config/help.txt[]
453 include::config/http.txt[]
455 include::config/i18n.txt[]
457 include::config/imap.txt[]
459 include::config/includeif.txt[]
461 include::config/index.txt[]
463 include::config/init.txt[]
465 include::config/instaweb.txt[]
467 include::config/interactive.txt[]
469 include::config/log.txt[]
471 include::config/lsrefs.txt[]
473 include::config/mailinfo.txt[]
475 include::config/mailmap.txt[]
477 include::config/maintenance.txt[]
479 include::config/man.txt[]
481 include::config/merge.txt[]
483 include::config/mergetool.txt[]
485 include::config/notes.txt[]
487 include::config/pack.txt[]
489 include::config/pager.txt[]
491 include::config/pretty.txt[]
493 include::config/promisor.txt[]
495 include::config/protocol.txt[]
497 include::config/pull.txt[]
499 include::config/push.txt[]
501 include::config/rebase.txt[]
503 include::config/receive.txt[]
505 include::config/reftable.txt[]
507 include::config/remote.txt[]
509 include::config/remotes.txt[]
511 include::config/repack.txt[]
513 include::config/rerere.txt[]
515 include::config/revert.txt[]
517 include::config/safe.txt[]
519 include::config/sendemail.txt[]
521 include::config/sequencer.txt[]
523 include::config/showbranch.txt[]
525 include::config/sparse.txt[]
527 include::config/splitindex.txt[]
529 include::config/ssh.txt[]
531 include::config/stash.txt[]
533 include::config/status.txt[]
535 include::config/submodule.txt[]
537 include::config/tag.txt[]
539 include::config/tar.txt[]
541 include::config/trace2.txt[]
543 include::config/transfer.txt[]
545 include::config/uploadarchive.txt[]
547 include::config/uploadpack.txt[]
549 include::config/url.txt[]
551 include::config/user.txt[]
553 include::config/versionsort.txt[]
555 include::config/web.txt[]
557 include::config/worktree.txt[]