]>
Commit | Line | Data |
---|---|---|
ee72aeaf JS |
1 | git-repo-config(1) |
2 | ================== | |
2d2465c0 JS |
3 | |
4 | NAME | |
5 | ---- | |
34eb3340 | 6 | git-repo-config - Get and set repository or global options. |
2d2465c0 JS |
7 | |
8 | ||
9 | SYNOPSIS | |
10 | -------- | |
c7569b1e | 11 | [verse] |
34eb3340 SE |
12 | 'git-repo-config' [--global] [type] name [value [value_regex]] |
13 | 'git-repo-config' [--global] [type] --replace-all name [value [value_regex]] | |
14 | 'git-repo-config' [--global] [type] --get name [value_regex] | |
15 | 'git-repo-config' [--global] [type] --get-all name [value_regex] | |
16 | 'git-repo-config' [--global] [type] --unset name [value_regex] | |
17 | 'git-repo-config' [--global] [type] --unset-all name [value_regex] | |
18 | 'git-repo-config' [--global] -l | --list | |
2d2465c0 JS |
19 | |
20 | DESCRIPTION | |
21 | ----------- | |
4ddba79d JS |
22 | You can query/set/replace/unset options with this command. The name is |
23 | actually the section and the key separated by a dot, and the value will be | |
24 | escaped. | |
2d2465c0 | 25 | |
6fe31e2e JH |
26 | If you want to set/unset an option which can occur on multiple |
27 | lines, a POSIX regexp `value_regex` needs to be given. Only the | |
28 | existing values that match the regexp are updated or unset. If | |
29 | you want to handle the lines that do *not* match the regex, just | |
30 | prepend a single exclamation mark in front (see EXAMPLES). | |
2d2465c0 | 31 | |
7162dff3 PB |
32 | The type specifier can be either '--int' or '--bool', which will make |
33 | 'git-repo-config' ensure that the variable(s) are of the given type and | |
34 | convert the value to the canonical form (simple decimal number for int, | |
35 | a "true" or "false" string for bool). If no type specifier is passed, | |
36 | no checks or transformations are performed on the value. | |
37 | ||
2b5f3ed3 | 38 | This command will fail if: |
2d2465c0 | 39 | |
2b5f3ed3 SE |
40 | . The .git/config file is invalid, |
41 | . Can not write to .git/config, | |
2d2465c0 JS |
42 | . no section was provided, |
43 | . the section or key is invalid, | |
34eb3340 SE |
44 | . you try to unset an option which does not exist, |
45 | . you try to unset/set an option for which multiple lines match, or | |
46 | . you use --global option without $HOME being properly set. | |
2d2465c0 JS |
47 | |
48 | ||
49 | OPTIONS | |
50 | ------- | |
51 | ||
4ddba79d | 52 | --replace-all:: |
abda1ef5 | 53 | Default behavior is to replace at most one line. This replaces |
2fa9a0fb | 54 | all lines matching the key (and optionally the value_regex). |
4ddba79d JS |
55 | |
56 | --get:: | |
57 | Get the value for a given key (optionally filtered by a regex | |
dc2613de PB |
58 | matching the value). Returns error code 1 if the key was not |
59 | found and error code 2 if multiple key values were found. | |
4ddba79d JS |
60 | |
61 | --get-all:: | |
62 | Like get, but does not fail if the number of values for the key | |
63 | is not exactly one. | |
64 | ||
2fa9a0fb JS |
65 | --get-regexp:: |
66 | Like --get-all, but interprets the name as a regular expression. | |
67 | ||
34eb3340 SE |
68 | --global:: |
69 | Use global ~/.gitconfig file rather than the repository .git/config. | |
70 | ||
2d2465c0 | 71 | --unset:: |
34eb3340 | 72 | Remove the line matching the key from config file. |
4ddba79d JS |
73 | |
74 | --unset-all:: | |
34eb3340 | 75 | Remove all matching lines from config file. |
2d2465c0 | 76 | |
de791f15 | 77 | -l, --list:: |
34eb3340 | 78 | List all variables set in config file. |
de791f15 | 79 | |
2d2465c0 | 80 | |
7f29f7a9 PB |
81 | ENVIRONMENT |
82 | ----------- | |
83 | ||
84 | GIT_CONFIG:: | |
85 | Take the configuration from the given file instead of .git/config. | |
34eb3340 | 86 | Using the "--global" option forces this to ~/.gitconfig. |
7f29f7a9 PB |
87 | |
88 | GIT_CONFIG_LOCAL:: | |
89 | Currently the same as $GIT_CONFIG; when Git will support global | |
90 | configuration files, this will cause it to take the configuration | |
91 | from the global configuration file in addition to the given file. | |
92 | ||
93 | ||
2d2465c0 JS |
94 | EXAMPLE |
95 | ------- | |
96 | ||
97 | Given a .git/config like this: | |
98 | ||
99 | # | |
100 | # This is the config file, and | |
101 | # a '#' or ';' character indicates | |
102 | # a comment | |
103 | # | |
104 | ||
105 | ; core variables | |
106 | [core] | |
107 | ; Don't trust file modes | |
108 | filemode = false | |
109 | ||
110 | ; Our diff algorithm | |
111 | [diff] | |
112 | external = "/usr/local/bin/gnu-diff -u" | |
113 | renames = true | |
114 | ||
115 | ; Proxy settings | |
1ab661dd PB |
116 | [core] |
117 | gitproxy="ssh" for "ssh://kernel.org/" | |
118 | gitproxy="proxy-command" for kernel.org | |
119 | gitproxy="myprotocol-command" for "my://" | |
120 | gitproxy=default-proxy ; for all the rest | |
2d2465c0 JS |
121 | |
122 | you can set the filemode to true with | |
123 | ||
124 | ------------ | |
ee72aeaf | 125 | % git repo-config core.filemode true |
2d2465c0 JS |
126 | ------------ |
127 | ||
addf88e4 PR |
128 | The hypothetical proxy command entries actually have a postfix to discern |
129 | what URL they apply to. Here is how to change the entry for kernel.org | |
2d2465c0 JS |
130 | to "ssh". |
131 | ||
132 | ------------ | |
1ab661dd | 133 | % git repo-config core.gitproxy '"ssh" for kernel.org' 'for kernel.org$' |
2d2465c0 JS |
134 | ------------ |
135 | ||
136 | This makes sure that only the key/value pair for kernel.org is replaced. | |
137 | ||
138 | To delete the entry for renames, do | |
139 | ||
140 | ------------ | |
ee72aeaf | 141 | % git repo-config --unset diff.renames |
2d2465c0 JS |
142 | ------------ |
143 | ||
1ab661dd | 144 | If you want to delete an entry for a multivar (like core.gitproxy above), |
4ddba79d JS |
145 | you have to provide a regex matching the value of exactly one line. |
146 | ||
147 | To query the value for a given key, do | |
2d2465c0 JS |
148 | |
149 | ------------ | |
ee72aeaf | 150 | % git repo-config --get core.filemode |
2d2465c0 JS |
151 | ------------ |
152 | ||
4ddba79d JS |
153 | or |
154 | ||
155 | ------------ | |
ee72aeaf | 156 | % git repo-config core.filemode |
4ddba79d JS |
157 | ------------ |
158 | ||
159 | or, to query a multivar: | |
160 | ||
161 | ------------ | |
1ab661dd | 162 | % git repo-config --get core.gitproxy "for kernel.org$" |
4ddba79d JS |
163 | ------------ |
164 | ||
165 | If you want to know all the values for a multivar, do: | |
166 | ||
167 | ------------ | |
1ab661dd | 168 | % git repo-config --get-all core.gitproxy |
4ddba79d JS |
169 | ------------ |
170 | ||
1ab661dd | 171 | If you like to live dangerous, you can replace *all* core.gitproxy by a |
4ddba79d JS |
172 | new one with |
173 | ||
174 | ------------ | |
1ab661dd | 175 | % git repo-config --replace-all core.gitproxy ssh |
4ddba79d | 176 | ------------ |
2d2465c0 | 177 | |
f98d863d JS |
178 | However, if you really only want to replace the line for the default proxy, |
179 | i.e. the one without a "for ..." postfix, do something like this: | |
180 | ||
181 | ------------ | |
1ab661dd | 182 | % git repo-config core.gitproxy ssh '! for ' |
f98d863d JS |
183 | ------------ |
184 | ||
185 | To actually match only values with an exclamation mark, you have to | |
186 | ||
187 | ------------ | |
ee72aeaf | 188 | % git repo-config section.key value '[!]' |
f98d863d JS |
189 | ------------ |
190 | ||
2d2465c0 | 191 | |
1ab661dd PB |
192 | include::config.txt[] |
193 | ||
194 | ||
2d2465c0 JS |
195 | Author |
196 | ------ | |
197 | Written by Johannes Schindelin <Johannes.Schindelin@gmx.de> | |
198 | ||
199 | Documentation | |
200 | -------------- | |
1ab661dd | 201 | Documentation by Johannes Schindelin, Petr Baudis and the git-list <git@vger.kernel.org>. |
2d2465c0 JS |
202 | |
203 | GIT | |
204 | --- | |
205 | Part of the gitlink:git[7] suite | |
206 |