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