Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/Documentation/config.adoc # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / Documentation / config.adoc` 635 lines ยท 21667 bytes Raw Blame History 1 CONFIGURATION FILE 2 ------------------ 3 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. 12 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 20 multivalued. 21 22 Syntax 23 ~~~~~~ 24 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. 29 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. 36 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: 40 41 -------- 42 [section "subsection"] 43 44 -------- 45 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 53 need to. 54 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. 59 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. 66 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. 73 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 `\`. 78 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. 83 84 85 Includes 86 ~~~~~~~~ 87 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" 92 below. 93 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. 98 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. 104 105 Conditional includes 106 ~~~~~~~~~~~~~~~~~~~~ 107 108 You can conditionally include a config file from another by setting an 109 `includeIf..path` variable to the name of the file to be 110 included. 111 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 114 are: 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 + 121 The .git location may be auto-discovered, or come from `$GIT_DIR` 122 environment variable. If the repository is auto-discovered via a .git 123 file (e.g. from submodules, or a linked worktree), the .git location 124 would be the final location where the .git directory is, not where the 125 .git file is. 126 + 127 The pattern can contain standard globbing wildcards and two additional 128 ones, `**/` and `/**`, that can match multiple path components. Please 129 refer 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 + 154 The worktree location is the path where files are checked out (as returned 155 by `git rev-parse --show-toplevel`). This is different from `gitdir`, which 156 matches the `.git` directory path. In a linked worktree, the worktree path 157 is the directory where that worktree's files are located, not the main 158 repository's `.git` directory. 159 + 160 The pattern uses the same glob syntax as `gitdir` (including `~/`, `./`, 161 `**/`, and trailing-`/` prefix matching). This condition will never match 162 in a bare repository (which has no worktree). 163 + 164 Unlike `gitdir`, the `worktree` condition currently matches only the 165 realpath-resolved worktree location. If the working tree was entered via a 166 symbolic link, a pattern that uses the symbolic-link spelling may not match; 167 use the real path instead. 168 + 169 This is useful when you want to apply configuration based on where the 170 working tree is located on the filesystem. For example, a contributor who 171 works on the same project both personally and as an employee can use 172 different `user.name` and `user.email` values depending on which directory 173 the 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 + 182 While `extensions.worktreeConfig` (see linkgit:git-worktree[1]) also supports 183 per-worktree configuration, it stores the config inside each repository's 184 `.git/config.worktree` file and requires running `git config --worktree` 185 inside each worktree individually. In contrast, `includeIf "worktree:..."` 186 can 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 188 their 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 + 202 If the pattern ends with `/`, `**` will be automatically added. For 203 example, the pattern `foo/` becomes `foo/**`. In other words, it matches 204 all branches that begin with `foo/`. This is useful if your branches are 205 organized hierarchically and you would like to apply a configuration to 206 all 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 + 217 Files included by this option (directly or indirectly) are not allowed 218 to contain remote URLs. 219 + 220 Note that unlike other includeIf conditions, resolving this condition 221 relies on information that is not yet known at the point of reading the 222 condition. A typical use case is this option being present as a 223 system-level or global-level config, and the remote URL being in a 224 local-level config; hence the need to scan ahead when resolving this 225 condition. In order to avoid the chicken-and-egg problem in which 226 potentially-included files can affect whether such files are potentially 227 included, Git breaks the cycle by prohibiting these files from affecting 228 the resolution of these conditions (thus, prohibiting them from 229 declaring remote URLs). 230 + 231 As for the naming of this keyword, it is for forwards compatibility with 232 a naming scheme that supports more variable-based include conditions, 233 but 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 + 240 Depending on how your system is configured, the hostname used for 241 matching may be short (e.g., "myhost") or a fully qualified domain 242 name ("myhost.example.com"). Run `git var GIT_HOSTNAME` to see the 243 hostname Git uses (see linkgit:git-var[1]). 244 245 A 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 + 254 This was not the case in the initial release of this feature in 255 v2.13.0, which only matched the realpath version. Configuration that 256 wants to be compatible with the initial release of this feature needs 257 to 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 262 Example 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 334 Values 335 ~~~~~~ 336 337 Values of many variables are treated as a simple string, but there 338 are variables that take values of specific types and there are rules 339 as to how to spell them. 340 341 boolean:: 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 `= ` 350 is taken as true. 351 352 false;; Boolean false literals are `no`, `off`, `false`, 353 `0` and the empty string. 354 -- 355 + 356 When converting a value to its canonical form using the `--type=bool` type 357 specifier, 'git config' will ensure that the output is "true" or 358 "false" (spelled in lowercase). 359 360 integer:: 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 365 color:: 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 + 370 The basic colors accepted are `normal`, `black`, `red`, `green`, 371 `yellow`, `blue`, `magenta`, `cyan`, `white` and `default`. The first 372 color given is the foreground; the second is the background. All the 373 basic colors except `normal` and `default` have a bright variant that can 374 be specified by prefixing the color with `bright`, like `brightred`. 375 + 376 The color `normal` makes no change to the color. It is the same as an 377 empty string, but can be used as the foreground color when specifying a 378 background color alone (for example, "normal red"). 379 + 380 The color `default` explicitly resets the color to the terminal default, 381 for example to specify a cleared background. Although it varies between 382 terminals, this is usually not the same as setting to "white black". 383 + 384 Colors may also be given as numbers between 0 and 255; these use ANSI 385 256-color mode (but note that not all terminals may support this). If 386 your terminal supports it, you may also specify 24-bit RGB values as 387 hex, like `#ff0ab3`, or 12-bit RGB values like `#f1b`, which is 388 equivalent to the 24-bit color `#ff11bb`. 389 + 390 The accepted attributes are `bold`, `dim`, `ul`, `blink`, `reverse`, 391 `italic`, and `strike` (for crossed-out or "strikethrough" letters). 392 The position of any attributes with respect to the colors 393 (before, after, or in between), doesn't matter. Specific attributes may 394 be turned off by prefixing them with `no` or `no-` (e.g., `noreverse`, 395 `no-ul`, etc). 396 + 397 The pseudo-attribute `reset` resets all colors and attributes before 398 applying the specified coloring. For example, `reset green` will result 399 in a green foreground and default background without any active 400 attributes. 401 + 402 An empty color string produces no color effect at all. This can be used 403 to avoid coloring specific elements without disabling color entirely. 404 + 405 For git's pre-defined color slots, the attributes are meant to be reset 406 at the beginning of each item in the colored output. So setting 407 `color.decorate.branch` to `black` will paint that branch name in a 408 plain `black`, even if the previous thing on the same output line (e.g. 409 opening parenthesis before the list of branch names in `log --decorate` 410 output) is set to be painted with `bold` or some other attribute. 411 However, custom log formats may do more complicated and layered 412 coloring, and the negated forms may be useful there. 413 414 pathname:: 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 + 421 If a path starts with `%(prefix)/`, the remainder is interpreted as a 422 path relative to Git's "runtime prefix", i.e. relative to the location 423 where Git itself was installed. For example, `%(prefix)/bin/` refers to 424 the directory in which the Git executable itself lives. If Git was 425 compiled without runtime prefix support, the compiled-in prefix will be 426 substituted instead. In the unlikely event that a literal path needs to 427 be specified that should _not_ be expanded, it needs to be prefixed by 428 `./`, like so: `./%(prefix)/bin`. 429 + 430 If prefixed with `:(optional)`, the configuration variable is treated 431 as if it does not exist, if the named path does not exist. 432 433 Variables 434 ~~~~~~~~~ 435 436 Note that this list is non-comprehensive and not necessarily complete. 437 For command-specific variables, you will find a more detailed description 438 in the appropriate manual page. 439 440 Other git-related tools may and do use their own variables. When 441 inventing new variables for use in your own tool, make sure their 442 names do not conflict with those that are used by Git itself and 443 other popular tools, and describe them in your documentation. 444 445 include::config/add.adoc[] 446 447 include::config/advice.adoc[] 448 449 include::config/alias.adoc[] 450 451 include::config/am.adoc[] 452 453 include::config/apply.adoc[] 454 455 include::config/attr.adoc[] 456 457 include::config/bitmap-pseudo-merge.adoc[] 458 459 include::config/blame.adoc[] 460 461 include::config/branch.adoc[] 462 463 include::config/browser.adoc[] 464 465 include::config/bundle.adoc[] 466 467 include::config/checkout.adoc[] 468 469 include::config/clean.adoc[] 470 471 include::config/clone.adoc[] 472 473 include::config/color.adoc[] 474 475 include::config/column.adoc[] 476 477 include::config/commit.adoc[] 478 479 include::config/commitgraph.adoc[] 480 481 include::config/completion.adoc[] 482 483 include::config/core.adoc[] 484 485 include::config/credential.adoc[] 486 487 include::config/diff.adoc[] 488 489 include::config/difftool.adoc[] 490 491 include::config/extensions.adoc[] 492 493 include::config/fastimport.adoc[] 494 495 include::config/feature.adoc[] 496 497 include::config/fetch.adoc[] 498 499 include::config/filter.adoc[] 500 501 include::config/format.adoc[] 502 503 include::config/fsck.adoc[] 504 505 include::config/fsmonitor--daemon.adoc[] 506 507 include::config/gc.adoc[] 508 509 include::config/gitcvs.adoc[] 510 511 include::config/gitweb.adoc[] 512 513 include::config/gpg.adoc[] 514 515 include::config/grep.adoc[] 516 517 include::config/gui.adoc[] 518 519 include::config/guitool.adoc[] 520 521 include::config/help.adoc[] 522 523 include::config/hook.adoc[] 524 525 include::config/http.adoc[] 526 527 include::config/i18n.adoc[] 528 529 include::config/imap.adoc[] 530 531 include::config/includeif.adoc[] 532 533 include::config/index.adoc[] 534 535 include::config/init.adoc[] 536 537 include::config/instaweb.adoc[] 538 539 include::config/interactive.adoc[] 540 541 include::config/log.adoc[] 542 543 include::config/lsrefs.adoc[] 544 545 include::config/mailinfo.adoc[] 546 547 include::config/mailmap.adoc[] 548 549 include::config/maintenance.adoc[] 550 551 include::config/man.adoc[] 552 553 include::config/merge.adoc[] 554 555 include::config/mergetool.adoc[] 556 557 include::config/notes.adoc[] 558 559 include::config/pack.adoc[] 560 561 include::config/pager.adoc[] 562 563 include::config/pretty.adoc[] 564 565 include::config/promisor.adoc[] 566 567 include::config/protocol.adoc[] 568 569 include::config/pull.adoc[] 570 571 include::config/push.adoc[] 572 573 include::config/rebase.adoc[] 574 575 include::config/receive.adoc[] 576 577 include::config/reftable.adoc[] 578 579 include::config/remote.adoc[] 580 581 include::config/remotes.adoc[] 582 583 include::config/repack.adoc[] 584 585 include::config/replay.adoc[] 586 587 include::config/rerere.adoc[] 588 589 include::config/revert.adoc[] 590 591 include::config/safe.adoc[] 592 593 include::config/sendemail.adoc[] 594 595 include::config/sequencer.adoc[] 596 597 include::config/showbranch.adoc[] 598 599 include::config/sideband.adoc[] 600 601 include::config/sparse.adoc[] 602 603 include::config/splitindex.adoc[] 604 605 include::config/ssh.adoc[] 606 607 include::config/stash.adoc[] 608 609 include::config/status.adoc[] 610 611 include::config/submodule.adoc[] 612 613 include::config/tag.adoc[] 614 615 include::config/tar.adoc[] 616 617 include::config/trace2.adoc[] 618 619 include::config/trailer.adoc[] 620 621 include::config/transfer.adoc[] 622 623 include::config/uploadarchive.adoc[] 624 625 include::config/uploadpack.adoc[] 626 627 include::config/url.adoc[] 628 629 include::config/user.adoc[] 630 631 include::config/versionsort.adoc[] 632 633 include::config/web.adoc[] 634 635 include::config/worktree.adoc[]