@@ -9,29 +9,22 @@ git-config - Get and set repository or global options
9
9
SYNOPSIS
10
10
--------
11
11
[verse]
12
- 'git config' [<file-option>] [--type=<type>] [--comment=<message>] [--fixed-value] [--show-origin] [--show-scope] [-z|--null] <name> [<value> [<value-pattern>]]
13
- 'git config' [<file-option>] [--type=<type>] [--comment=<message>] --add <name> <value>
14
- 'git config' [<file-option>] [--type=<type>] [--comment=<message>] [--fixed-value] --replace-all <name> <value> [<value-pattern>]
15
- 'git config' [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] --get <name> [<value-pattern>]
16
- 'git config' [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] --get-all <name> [<value-pattern>]
17
- 'git config' [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] [--name-only] --get-regexp <name-regex> [<value-pattern>]
18
- 'git config' [<file-option>] [--type=<type>] [-z|--null] --get-urlmatch <name> <URL>
19
- 'git config' [<file-option>] [--fixed-value] --unset <name> [<value-pattern>]
20
- 'git config' [<file-option>] [--fixed-value] --unset-all <name> [<value-pattern>]
21
- 'git config' [<file-option>] --rename-section <old-name> <new-name>
22
- 'git config' [<file-option>] --remove-section <name>
23
- 'git config' [<file-option>] [--show-origin] [--show-scope] [-z|--null] [--name-only] -l | --list
24
- 'git config' [<file-option>] --get-color <name> [<default>]
12
+ 'git config list' [<file-option>] [<display-option>] [--includes]
13
+ 'git config get' [<file-option>] [<display-option>] [--includes] [--all] [--regexp=<regexp>] [--value=<value>] [--fixed-value] [--default=<default>] <name>
14
+ 'git config set' [<file-option>] [--type=<type>] [--all] [--value=<value>] [--fixed-value] <name> <value>
15
+ 'git config unset' [<file-option>] [--all] [--value=<value>] [--fixed-value] <name> <value>
16
+ 'git config rename-section' [<file-option>] <old-name> <new-name>
17
+ 'git config remove-section' [<file-option>] <name>
18
+ 'git config edit' [<file-option>]
25
19
'git config' [<file-option>] --get-colorbool <name> [<stdout-is-tty>]
26
- 'git config' [<file-option>] -e | --edit
27
20
28
21
DESCRIPTION
29
22
-----------
30
23
You can query/set/replace/unset options with this command. The name is
31
24
actually the section and the key separated by a dot, and the value will be
32
25
escaped.
33
26
34
- Multiple lines can be added to an option by using the `--add ` option.
27
+ Multiple lines can be added to an option by using the `--append ` option.
35
28
If you want to update or unset an option which can occur on multiple
36
29
lines, a `value-pattern` (which is an extended regular expression,
37
30
unless the `--fixed-value` option is given) needs to be given. Only the
@@ -74,6 +67,42 @@ On success, the command returns the exit code 0.
74
67
A list of all available configuration variables can be obtained using the
75
68
`git help --config` command.
76
69
70
+ COMMANDS
71
+ --------
72
+
73
+ list::
74
+ List all variables set in config file, along with their values.
75
+
76
+ get::
77
+ Emits the value of the specified key. If key is present multiple times
78
+ in the configuration, emits the last value. If `--all` is specified,
79
+ emits all values associated with key. Returns error code 1 if key is
80
+ not present.
81
+
82
+ set::
83
+ Set value for one or more config options. By default, this command
84
+ refuses to write multi-valued config options. Passing `--all` will
85
+ replace all multi-valued config options with the new value, whereas
86
+ `--value=` will replace all config options whose values match the given
87
+ pattern.
88
+
89
+ unset::
90
+ Unset value for one or more config options. By default, this command
91
+ refuses to unset multi-valued keys. Passing `--all` will unset all
92
+ multi-valued config options, whereas `--value` will unset all config
93
+ options whose values match the given pattern.
94
+
95
+ rename-section::
96
+ Rename the given section to a new name.
97
+
98
+ remove-section::
99
+ Remove the given section from the configuration file.
100
+
101
+ edit::
102
+ Opens an editor to modify the specified config file; either
103
+ `--system`, `--global`, `--local` (default), `--worktree`, or
104
+ `--file <config-file>`.
105
+
77
106
[[OPTIONS]]
78
107
OPTIONS
79
108
-------
@@ -82,10 +111,9 @@ OPTIONS
82
111
Default behavior is to replace at most one line. This replaces
83
112
all lines matching the key (and optionally the `value-pattern`).
84
113
85
- --add ::
114
+ --append ::
86
115
Adds a new line to the option without altering any existing
87
- values. This is the same as providing '^$' as the `value-pattern`
88
- in `--replace-all`.
116
+ values. This is the same as providing '--value=^$' in `set`.
89
117
90
118
--comment <message>::
91
119
Append a comment at the end of new or modified lines.
@@ -99,22 +127,16 @@ OPTIONS
99
127
not contain linefeed characters (no multi-line comments are
100
128
permitted).
101
129
102
- --get::
103
- Get the value for a given key (optionally filtered by a regex
104
- matching the value). Returns error code 1 if the key was not
105
- found and the last value if multiple key values were found.
130
+ --all::
131
+ With `get`, return all values for a multi-valued key.
106
132
107
- --get-all::
108
- Like get, but returns all values for a multi-valued key.
133
+ ---regexp::
134
+ With `get`, interpret the name as a regular expression. Regular
135
+ expression matching is currently case-sensitive and done against a
136
+ canonicalized version of the key in which section and variable names
137
+ are lowercased, but subsection names are not.
109
138
110
- --get-regexp::
111
- Like --get-all, but interprets the name as a regular expression and
112
- writes out the key names. Regular expression matching is currently
113
- case-sensitive and done against a canonicalized version of the key
114
- in which section and variable names are lowercased, but subsection
115
- names are not.
116
-
117
- --get-urlmatch <name> <URL>::
139
+ --url=<URL>::
118
140
When given a two-part <name> as <section>.<key>, the value for
119
141
<section>.<URL>.<key> whose <URL> part matches the best to the
120
142
given URL is returned (if no such key exists, the value for
@@ -178,22 +200,6 @@ See also <<FILES>>.
178
200
section in linkgit:gitrevisions[7] for a more complete list of
179
201
ways to spell blob names.
180
202
181
- --remove-section::
182
- Remove the given section from the configuration file.
183
-
184
- --rename-section::
185
- Rename the given section to a new name.
186
-
187
- --unset::
188
- Remove the line matching the key from config file.
189
-
190
- --unset-all::
191
- Remove all lines matching the key from config file.
192
-
193
- -l::
194
- --list::
195
- List all variables set in config file, along with their values.
196
-
197
203
--fixed-value::
198
204
When used with the `value-pattern` argument, treat `value-pattern` as
199
205
an exact string instead of a regular expression. This will restrict
@@ -248,8 +254,8 @@ Valid `<type>`'s include:
248
254
contain line breaks.
249
255
250
256
--name-only::
251
- Output only the names of config variables for `-- list` or
252
- `-- get-regexp `.
257
+ Output only the names of config variables for `list` or
258
+ `get`.
253
259
254
260
--show-origin::
255
261
Augment the output of all queried config options with the
@@ -273,38 +279,71 @@ Valid `<type>`'s include:
273
279
When the color setting for `name` is undefined, the command uses
274
280
`color.ui` as fallback.
275
281
276
- --get-color <name> [<default>]::
277
-
278
- Find the color configured for `name` (e.g. `color.diff.new`) and
279
- output it as the ANSI color escape sequence to the standard
280
- output. The optional `default` parameter is used instead, if
281
- there is no color configured for `name`.
282
- +
283
- `--type=color [--default=<default>]` is preferred over `--get-color`
284
- (but note that `--get-color` will omit the trailing newline printed by
285
- `--type=color`).
286
-
287
- -e::
288
- --edit::
289
- Opens an editor to modify the specified config file; either
290
- `--system`, `--global`, `--local` (default), `--worktree`, or
291
- `--file <config-file>`.
292
-
293
282
--[no-]includes::
294
283
Respect `include.*` directives in config files when looking up
295
284
values. Defaults to `off` when a specific file is given (e.g.,
296
285
using `--file`, `--global`, etc) and `on` when searching all
297
286
config files.
298
287
299
288
--default <value>::
300
- When using `-- get`, and the requested variable is not found, behave as if
289
+ When using `get`, and the requested variable is not found, behave as if
301
290
<value> were the value assigned to that variable.
302
291
292
+ DEPRECATED MODES
293
+ ----------------
294
+
295
+ The following modes have been deprecated in favor of subcommands. It is
296
+ recommended to migrate to the new syntax.
297
+
298
+ 'git config <name>'::
299
+ Replaced by `git config get <name>`.
300
+
301
+ 'git config <name> <value> [<value-pattern>]'::
302
+ Replaced by `git config set [--value=<pattern>] <name> <value>`.
303
+
304
+ -l::
305
+ --list::
306
+ Replaced by `git config list`.
307
+
308
+ --get <name> [<value-pattern>]::
309
+ Replaced by `git config get [--value=<pattern>] <name>`.
310
+
311
+ --get-all <name> [<value-pattern>]::
312
+ Replaced by `git config get [--value=<pattern>] --all --show-names <name>`.
313
+
314
+ --get-regexp <name-regexp>::
315
+ Replaced by `git config get --all --show-names --regexp <name-regexp>`.
316
+
317
+ --get-urlmatch <name> <URL>::
318
+ Replaced by `git config get --all --show-names --url=<URL> <name>`.
319
+
320
+ --get-color <name> [<default>]::
321
+ Replaced by `git config get --type=color [--default=<default>] <name>`.
322
+
323
+ --add <name> <value>::
324
+ Replaced by `git config set --append <name> <value>`.
325
+
326
+ --unset <name> [<value-pattern>]::
327
+ Replaced by `git config unset [--value=<pattern>] <name>`.
328
+
329
+ --unset-all <name> [<value-pattern>]::
330
+ Replaced by `git config unset [--value=<pattern>] --all <name>`.
331
+
332
+ --rename-section <old-name> <new-name>::
333
+ Replaced by `git config rename-section <old-name> <new-name>`.
334
+
335
+ --remove-section <name>::
336
+ Replaced by `git config remove-section <name>`.
337
+
338
+ -e::
339
+ --edit::
340
+ Replaced by `git config edit`.
341
+
303
342
CONFIGURATION
304
343
-------------
305
344
`pager.config` is only respected when listing configuration, i.e., when
306
- using `-- list` or any of the `-- get-* ` which may return multiple results.
307
- The default is to use a pager.
345
+ using `list` or ` get` which may return multiple results. The default is to use
346
+ a pager.
308
347
309
348
[[FILES]]
310
349
FILES
@@ -346,8 +385,8 @@ precedence over values read earlier. When multiple values are taken then all
346
385
values of a key from all files will be used.
347
386
348
387
By default, options are only written to the repository specific
349
- configuration file. Note that this also affects options like `--replace-all `
350
- and `-- unset`. *'git config' will only ever change one file at a time*.
388
+ configuration file. Note that this also affects options like `set `
389
+ and `unset`. *'git config' will only ever change one file at a time*.
351
390
352
391
You can limit which configuration sources are read from or written to by
353
392
specifying the path of a file with the `--file` option, or by specifying a
@@ -482,23 +521,23 @@ Given a .git/config like this:
482
521
you can set the filemode to true with
483
522
484
523
------------
485
- % git config core.filemode true
524
+ % git config set core.filemode true
486
525
------------
487
526
488
527
The hypothetical proxy command entries actually have a postfix to discern
489
528
what URL they apply to. Here is how to change the entry for kernel.org
490
529
to "ssh".
491
530
492
531
------------
493
- % git config core.gitproxy '"ssh" for kernel.org' ' for kernel.org$ '
532
+ % git config set --value=' for kernel.org$' core.gitproxy '"ssh" for kernel.org'
494
533
------------
495
534
496
535
This makes sure that only the key/value pair for kernel.org is replaced.
497
536
498
537
To delete the entry for renames, do
499
538
500
539
------------
501
- % git config -- unset diff.renames
540
+ % git config unset diff.renames
502
541
------------
503
542
504
543
If you want to delete an entry for a multivar (like core.gitproxy above),
@@ -507,72 +546,66 @@ you have to provide a regex matching the value of exactly one line.
507
546
To query the value for a given key, do
508
547
509
548
------------
510
- % git config --get core.filemode
511
- ------------
512
-
513
- or
514
-
515
- ------------
516
- % git config core.filemode
549
+ % git config get core.filemode
517
550
------------
518
551
519
552
or, to query a multivar:
520
553
521
554
------------
522
- % git config -- get core.gitproxy "for kernel.org$"
555
+ % git config get --value= "for kernel.org$" core.gitproxy
523
556
------------
524
557
525
558
If you want to know all the values for a multivar, do:
526
559
527
560
------------
528
- % git config -- get- all core.gitproxy
561
+ % git config get -- all --show-names core.gitproxy
529
562
------------
530
563
531
564
If you like to live dangerously, you can replace *all* core.gitproxy by a
532
565
new one with
533
566
534
567
------------
535
- % git config --replace -all core.gitproxy ssh
568
+ % git config set - -all core.gitproxy ssh
536
569
------------
537
570
538
571
However, if you really only want to replace the line for the default proxy,
539
572
i.e. the one without a "for ..." postfix, do something like this:
540
573
541
574
------------
542
- % git config core.gitproxy ssh '! for '
575
+ % git config set --value= '! for ' core.gitproxy ssh
543
576
------------
544
577
545
578
To actually match only values with an exclamation mark, you have to
546
579
547
580
------------
548
- % git config section.key value '[!]'
581
+ % git config set -- value= '[!]' section.key value
549
582
------------
550
583
551
584
To add a new proxy, without altering any of the existing ones, use
552
585
553
586
------------
554
- % git config --add core.gitproxy '"proxy-command" for example.com'
587
+ % git config set --append core.gitproxy '"proxy-command" for example.com'
555
588
------------
556
589
557
590
An example to use customized color from the configuration in your
558
591
script:
559
592
560
593
------------
561
594
#!/bin/sh
562
- WS=$(git config -- get- color color.diff.whitespace "blue reverse")
563
- RESET=$(git config -- get- color " " "reset ")
595
+ WS=$(git config get --type= color --default= "blue reverse" color.diff.whitespace )
596
+ RESET=$(git config get --type= color --default="reset " "")
564
597
echo "${WS}your whitespace color or blue reverse${RESET}"
565
598
------------
566
599
567
600
For URLs in `https://weak.example.com`, `http.sslVerify` is set to
568
601
false, while it is set to `true` for all others:
569
602
570
603
------------
571
- % git config --type=bool --get-urlmatch http.sslverify https://good.example.com
604
+ % git config get --type=bool --url= https://good.example.com http.sslverify
572
605
true
573
- % git config --type=bool --get-urlmatch http.sslverify https://weak.example.com
606
+ % git config get --type=bool --url= https://weak.example.com http.sslverify
574
607
false
575
- % git config -- get-urlmatch http https://weak.example.com
608
+ % git config get --url= https://weak.example.com http
576
609
http.cookieFile /tmp/cookie.txt
577
610
http.sslverify false
578
611
------------
0 commit comments