]>
Commit | Line | Data |
---|---|---|
1ab661dd PB |
1 | CONFIGURATION FILE |
2 | ------------------ | |
3 | ||
2de9b711 | 4 | The Git configuration file contains a number of variables that affect |
58b284a2 | 5 | the Git commands' behavior. The files `.git/config` and optionally |
bdccbf70 MT |
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. | |
5ea5621f | 12 | |
2de9b711 | 13 | The configuration variables are used by both the Git plumbing |
b7ee2266 SB |
14 | and the porcelains. The variables are divided into sections, wherein |
15 | the fully qualified variable name of the variable itself is the last | |
1ab661dd | 16 | dot-separated segment and the section name is everything before the last |
e0a4aae8 LP |
17 | dot. The variable names are case-insensitive, allow only alphanumeric |
18 | characters and `-`, and must start with an alphabetic character. Some | |
a5285b6c JH |
19 | variables may appear multiple times; we say then that the variable is |
20 | multivalued. | |
1ab661dd | 21 | |
e136f33b JN |
22 | Syntax |
23 | ~~~~~~ | |
24 | ||
1ab661dd | 25 | The syntax is fairly flexible and permissive; whitespaces are mostly |
e136f33b JN |
26 | ignored. The '#' and ';' characters begin comments to the end of line, |
27 | blank lines are ignored. | |
28 | ||
29 | The file consists of sections and variables. A section begins with | |
30 | the name of the section in square brackets and continues until the next | |
05c3e5c7 | 31 | section begins. Section names are case-insensitive. Only alphanumeric |
dcb11263 | 32 | characters, `-` and `.` are allowed in section names. Each variable |
773002a7 SB |
33 | must belong to some section, which means that there must be a section |
34 | header before the first setting of a variable. | |
e136f33b JN |
35 | |
36 | Sections can be further divided into subsections. To begin a subsection | |
37 | put its name in double quotes, separated by space from the section name, | |
773002a7 | 38 | in the section header, like in the example below: |
e136f33b JN |
39 | |
40 | -------- | |
41 | [section "subsection"] | |
42 | ||
43 | -------- | |
44 | ||
b7ee2266 | 45 | Subsection names are case sensitive and can contain any characters except |
1feb0617 DB |
46 | newline and the null byte. Doublequote `"` and backslash can be included |
47 | by escaping them as `\"` and `\\`, respectively. Backslashes preceding | |
48 | other 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. | |
50 | Variables may belong directly to a section or to a given subsection. You | |
51 | can have `[section]` if you have `[section "subsection"]`, but you don't | |
52 | need to. | |
e136f33b | 53 | |
f7376329 CMN |
54 | There is also a deprecated `[section.subsection]` syntax. With this |
55 | syntax, the subsection name is converted to lower-case and is also | |
56 | compared case sensitively. These subsection names follow the same | |
57 | restrictions as section names. | |
e136f33b | 58 | |
2ceb639f NS |
59 | All the other lines (and the remainder of the line after the section |
60 | header) are recognized as setting variables, in the form | |
1c448b3b JH |
61 | 'name = value' (or just 'name', which is a short-hand to say that |
62 | the variable is the boolean "true"). | |
e0a4aae8 | 63 | The variable names are case-insensitive, allow only alphanumeric characters |
a5285b6c | 64 | and `-`, and must start with an alphabetic character. |
e136f33b | 65 | |
ff5507ed JH |
66 | A line that defines a value can be continued to the next line by |
67 | ending it with a `\`; the backquote and the end-of-line are | |
68 | stripped. Leading whitespaces after 'name =', the remainder of the | |
69 | line after the first comment character '#' or ';', and trailing | |
70 | whitespaces of the line are discarded unless they are enclosed in | |
71 | double quotes. Internal whitespaces within the value are retained | |
72 | verbatim. | |
e136f33b | 73 | |
ff5507ed JH |
74 | Inside double quotes, double quote `"` and backslash `\` characters |
75 | must be escaped: use `\"` for `"` and `\\` for `\`. | |
e136f33b | 76 | |
dcb11263 CJ |
77 | The following escape sequences (beside `\"` and `\\`) are recognized: |
78 | `\n` for newline character (NL), `\t` for horizontal tabulation (HT, TAB) | |
a58088ab JL |
79 | and `\b` for backspace (BS). Other char escape sequences (including octal |
80 | escape sequences) are invalid. | |
e136f33b | 81 | |
1ab661dd | 82 | |
9b25a0b5 JK |
83 | Includes |
84 | ~~~~~~~~ | |
85 | ||
9d71d94d JK |
86 | The `include` and `includeIf` sections allow you to include config |
87 | directives from another source. These sections behave identically to | |
88 | each other with the exception that `includeIf` sections may be ignored | |
89 | if their condition does not evaluate to true; see "Conditional includes" | |
90 | below. | |
91 | ||
df0233be | 92 | You can include a config file from another by setting the special |
9d71d94d JK |
93 | `include.path` (or `includeIf.*.path`) variable to the name of the file |
94 | to be included. The variable takes a pathname as its value, and is | |
95 | subject to tilde expansion. These variables can be given multiple times. | |
dca83abd | 96 | |
a076df28 JK |
97 | The contents of the included file are inserted immediately, as if they |
98 | had been found at the location of the include directive. If the value of the | |
9d71d94d | 99 | variable is a relative path, the path is considered to |
1050e987 NTND |
100 | be relative to the configuration file in which the include directive |
101 | was found. See below for examples. | |
dca83abd | 102 | |
3efd0bed NTND |
103 | Conditional includes |
104 | ~~~~~~~~~~~~~~~~~~~~ | |
105 | ||
106 | You can include a config file from another conditionally by setting a | |
107 | `includeIf.<condition>.path` variable to the name of the file to be | |
9d71d94d | 108 | included. |
3efd0bed NTND |
109 | |
110 | The condition starts with a keyword followed by a colon and some data | |
111 | whose format and meaning depends on the keyword. Supported keywords | |
112 | are: | |
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 | + | |
120 | The .git location may be auto-discovered, or come from `$GIT_DIR` | |
121 | environment variable. If the repository is auto discovered via a .git | |
122 | file (e.g. from submodules, or a linked worktree), the .git location | |
123 | would be the final location where the .git directory is, not where the | |
124 | .git file is. | |
125 | + | |
126 | The pattern can contain standard globbing wildcards and two additional | |
127 | ones, `**/` and `/**`, that can match multiple path components. Please | |
128 | refer 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 | |
031fd4b9 | 146 | case-insensitively (e.g. on case-insensitive file systems) |
3efd0bed | 147 | |
07b2c0ea DL |
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 | + | |
156 | If the pattern ends with `/`, `**` will be automatically added. For | |
157 | example, the pattern `foo/` becomes `foo/**`. In other words, it matches | |
158 | all branches that begin with `foo/`. This is useful if your branches are | |
159 | organized hierarchically and you would like to apply a configuration to | |
160 | all the branches in that hierarchy. | |
161 | ||
3efd0bed NTND |
162 | A few more notes on matching via `gitdir` and `gitdir/i`: |
163 | ||
164 | * Symlinks in `$GIT_DIR` are not resolved before matching. | |
165 | ||
0624c63c ÆAB |
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 | + | |
171 | This was not the case in the initial release of this feature in | |
172 | v2.13.0, which only matched the realpath version. Configuration that | |
173 | wants to be compatible with the initial release of this feature needs | |
174 | to either specify only the realpath version, or both versions. | |
175 | ||
3efd0bed NTND |
176 | * Note that "../" is not special and will match literally, which is |
177 | unlikely what you want. | |
9b25a0b5 | 178 | |
1ab661dd PB |
179 | Example |
180 | ~~~~~~~ | |
181 | ||
1925fe0c MÅ |
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 | |
994cd6c7 | 224 | |
76ba7fa2 MÅ |
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 | ---- | |
07b2c0ea | 230 | |
5f7b91ba JH |
231 | Values |
232 | ~~~~~~ | |
233 | ||
234 | Values of many variables are treated as a simple string, but there | |
235 | are variables that take values of specific types and there are rules | |
236 | as to how to spell them. | |
237 | ||
238 | boolean:: | |
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 | ||
7f0a02be AH |
244 | true;; Boolean true literals are `yes`, `on`, `true`, |
245 | and `1`. Also, a variable defined without `= <value>` | |
5f7b91ba JH |
246 | is taken as true. |
247 | ||
7f0a02be AH |
248 | false;; Boolean false literals are `no`, `off`, `false`, |
249 | `0` and the empty string. | |
5f7b91ba | 250 | + |
ed3bb3df | 251 | When converting a value to its canonical form using the `--type=bool` type |
7f0a02be | 252 | specifier, 'git config' will ensure that the output is "true" or |
5f7b91ba JH |
253 | "false" (spelled in lowercase). |
254 | ||
255 | integer:: | |
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 | ||
b92c1a28 | 260 | color:: |
adb33566 JK |
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. | |
5f456b3c | 264 | + |
adb33566 JK |
265 | The basic colors accepted are `normal`, `black`, `red`, `green`, `yellow`, |
266 | `blue`, `magenta`, `cyan` and `white`. The first color given is the | |
1751b09a ES |
267 | foreground; the second is the background. All the basic colors except |
268 | `normal` have a bright variant that can be speficied by prefixing the | |
269 | color with `bright`, like `brightred`. | |
5ee87585 | 270 | + |
adb33566 JK |
271 | Colors may also be given as numbers between 0 and 255; these use ANSI |
272 | 256-color mode (but note that not all terminals may support this). If | |
273 | your terminal supports it, you may also specify 24-bit RGB values as | |
274 | hex, like `#ff0ab3`. | |
275 | + | |
9dc3515c JK |
276 | The accepted attributes are `bold`, `dim`, `ul`, `blink`, `reverse`, |
277 | `italic`, and `strike` (for crossed-out or "strikethrough" letters). | |
278 | The position of any attributes with respect to the colors | |
54590a0e JK |
279 | (before, after, or in between), doesn't matter. Specific attributes may |
280 | be turned off by prefixing them with `no` or `no-` (e.g., `noreverse`, | |
281 | `no-ul`, etc). | |
adb33566 | 282 | + |
512aba26 JK |
283 | An empty color string produces no color effect at all. This can be used |
284 | to avoid coloring specific elements without disabling color entirely. | |
285 | + | |
adb33566 JK |
286 | For git's pre-defined color slots, the attributes are meant to be reset |
287 | at the beginning of each item in the colored output. So setting | |
288 | `color.decorate.branch` to `black` will paint that branch name in a | |
289 | plain `black`, even if the previous thing on the same output line (e.g. | |
290 | opening parenthesis before the list of branch names in `log --decorate` | |
291 | output) is set to be painted with `bold` or some other attribute. | |
292 | However, custom log formats may do more complicated and layered | |
293 | coloring, and the negated forms may be useful there. | |
b92c1a28 | 294 | |
dca83abd JH |
295 | pathname:: |
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 | ||
5f7b91ba | 302 | |
1ab661dd PB |
303 | Variables |
304 | ~~~~~~~~~ | |
305 | ||
306 | Note that this list is non-comprehensive and not necessarily complete. | |
b8936cf0 | 307 | For command-specific variables, you will find a more detailed description |
93728b23 CA |
308 | in the appropriate manual page. |
309 | ||
310 | Other git-related tools may and do use their own variables. When | |
311 | inventing new variables for use in your own tool, make sure their | |
312 | names do not conflict with those that are used by Git itself and | |
313 | other popular tools, and describe them in your documentation. | |
314 | ||
838ef420 | 315 | include::config/advice.txt[] |
75194438 | 316 | |
1a394fa9 | 317 | include::config/core.txt[] |
dce96489 | 318 | |
29120d8e | 319 | include::config/add.txt[] |
13bd2134 | 320 | |
f740c8f1 | 321 | include::config/alias.txt[] |
dfd42a3c | 322 | |
d293ffef | 323 | include::config/am.txt[] |
e97a5e76 | 324 | |
696d4796 | 325 | include::config/apply.txt[] |
1ab661dd | 326 | |
d09467b6 | 327 | include::config/blame.txt[] |
8578037b | 328 | |
7273b95d | 329 | include::config/branch.txt[] |
a5ba2cbe | 330 | |
6b0b9740 | 331 | include::config/browser.txt[] |
584627b4 | 332 | |
9140b410 | 333 | include::config/checkout.txt[] |
fa655d84 | 334 | |
328e629c | 335 | include::config/clean.txt[] |
2122591b | 336 | |
0a7839e3 | 337 | include::config/color.txt[] |
6b2f2d98 | 338 | |
dbfc949f | 339 | include::config/column.txt[] |
d96e3c15 | 340 | |
5453d236 | 341 | include::config/commit.txt[] |
aaab8420 | 342 | |
3a49be6d | 343 | include::config/credential.txt[] |
7f4d4746 | 344 | |
2b4b7305 | 345 | include::config/completion.txt[] |
6532f374 | 346 | |
fa922d74 | 347 | include::config/diff.txt[] |
afcbc8e7 | 348 | |
9155f6f6 | 349 | include::config/difftool.txt[] |
a904392e | 350 | |
f2e58246 | 351 | include::config/fastimport.txt[] |
d9545c7f | 352 | |
c6cc4c5a DS |
353 | include::config/feature.txt[] |
354 | ||
561fda20 | 355 | include::config/fetch.txt[] |
42cc7485 | 356 | |
ab14f494 | 357 | include::config/format.txt[] |
bb52995f | 358 | |
734dfebb | 359 | include::config/filter.txt[] |
26488f59 | 360 | |
f80ccccb | 361 | include::config/fsck.txt[] |
1335f732 | 362 | |
8daf3271 | 363 | include::config/gc.txt[] |
48c32424 | 364 | |
996f66eb | 365 | include::config/gitcvs.txt[] |
04752868 | 366 | |
0648b769 | 367 | include::config/gitweb.txt[] |
cd82323f | 368 | |
434e6e75 | 369 | include::config/grep.txt[] |
ecd9ba61 | 370 | |
ea555d04 | 371 | include::config/gpg.txt[] |
b02f51b1 | 372 | |
d864cf8b | 373 | include::config/gui.txt[] |
a2df1fb2 | 374 | |
2c31a830 | 375 | include::config/guitool.txt[] |
390c3480 | 376 | |
d3df4270 | 377 | include::config/help.txt[] |
b1f809d0 | 378 | |
ad308479 | 379 | include::config/http.txt[] |
6a56993b | 380 | |
8fc3f75f | 381 | include::config/i18n.txt[] |
d2c11a38 | 382 | |
ae461026 | 383 | include::config/imap.txt[] |
b0f34c3d | 384 | |
c1b342ad | 385 | include::config/index.txt[] |
3c09d684 | 386 | |
ec335607 | 387 | include::config/init.txt[] |
d8a8488d | 388 | |
cef9b951 | 389 | include::config/instaweb.txt[] |
983a9eeb | 390 | |
630c2738 | 391 | include::config/interactive.txt[] |
01143847 | 392 | |
83009762 | 393 | include::config/log.txt[] |
e6bb5f78 | 394 | |
55e51cd7 | 395 | include::config/mailinfo.txt[] |
d5c4b185 | 396 | |
4a9f0c52 | 397 | include::config/mailmap.txt[] |
08610900 | 398 | |
f7ade6c9 | 399 | include::config/man.txt[] |
7e8114c0 | 400 | |
7fb5ab4a | 401 | include::config/merge.txt[] |
b5412484 | 402 | |
ea24a76a | 403 | include::config/mergetool.txt[] |
682b451f | 404 | |
e50472d8 | 405 | include::config/notes.txt[] |
6956f858 | 406 | |
a168c5a2 | 407 | include::config/pack.txt[] |
ae4f07fb | 408 | |
87e1b41a | 409 | include::config/pager.txt[] |
4370c2d6 | 410 | |
cd967547 | 411 | include::config/pretty.txt[] |
8028184e | 412 | |
dd55172c | 413 | include::config/protocol.txt[] |
373d70ef | 414 | |
7f50a495 | 415 | include::config/pull.txt[] |
d8052750 | 416 | |
d15dc439 | 417 | include::config/push.txt[] |
b33a15b0 | 418 | |
c7245900 | 419 | include::config/rebase.txt[] |
16cf51c7 | 420 | |
5f5a5fca | 421 | include::config/receive.txt[] |
0a1bc12b | 422 | |
99fce397 | 423 | include::config/remote.txt[] |
737c5a9c | 424 | |
b720a9db | 425 | include::config/remotes.txt[] |
1918278e | 426 | |
be958be2 | 427 | include::config/repack.txt[] |
ee34a2be | 428 | |
72622c24 | 429 | include::config/rerere.txt[] |
b0f34c3d | 430 | |
e344b8b4 | 431 | include::config/reset.txt[] |
4c3abd05 | 432 | |
0ee42c86 | 433 | include::config/sendemail.txt[] |
5453b83b | 434 | |
c3324199 | 435 | include::config/sequencer.txt[] |
8dc9d22d | 436 | |
c52bcbb6 | 437 | include::config/showbranch.txt[] |
1ab661dd | 438 | |
2ef0e469 | 439 | include::config/splitindex.txt[] |
b2dd1c5c | 440 | |
12e60249 NTND |
441 | include::config/ssh.txt[] |
442 | ||
54ff5dda | 443 | include::config/status.txt[] |
4b2343fa | 444 | |
46a8bbb2 | 445 | include::config/stash.txt[] |
3086c064 | 446 | |
95c125f2 | 447 | include::config/submodule.txt[] |
31224cbd | 448 | |
fb4c06fa | 449 | include::config/tag.txt[] |
ce1a79b6 | 450 | |
8312aa7d JH |
451 | include::config/tar.txt[] |
452 | ||
81567caf JH |
453 | include::config/trace2.txt[] |
454 | ||
4a5bad07 | 455 | include::config/transfer.txt[] |
b0f34c3d | 456 | |
c61f5562 | 457 | include::config/uploadarchive.txt[] |
7671b632 | 458 | |
533fff6a | 459 | include::config/uploadpack.txt[] |
516e2b76 | 460 | |
e4a7a7b0 | 461 | include::config/url.txt[] |
1c2eafb8 | 462 | |
18b421d4 | 463 | include::config/user.txt[] |
d67778ec | 464 | |
25268ad5 | 465 | include::config/versionsort.txt[] |
d811c8e1 | 466 | |
07c11a0b | 467 | include::config/web.txt[] |
e92445a7 | 468 | |
649cf589 | 469 | include::config/worktree.txt[] |