git config
本文是有关Git的配置。
# list the usage of git config.
git config
如下是Git Config的帮助文档,这些基本用法经过组合,就是Git配置的常用操作方法。
usage: git config [options]
Config file location
--global use global config file
--system use system config file
--local use repository config file
-f, --file <file> use given config file
--blob <blob-id> read config from given blob object
Action
--get get value: name [value-regex]
--get-all get all values: key [value-regex]
--get-regexp get values for regexp: name-regex [value-regex]
--replace-all replace all matching variables: name value [value_regex]
--add add a new variable: name value
--unset remove a variable: name [value-regex]
--unset-all remove all matches: name [value-regex]
--rename-section rename section: old-name new-name
--remove-section remove a section: name
-l, --list list all
-e, --edit open an editor
--get-color <slot> find the color configured: [default]
--get-colorbool <slot>
find the color setting: [stdout-is-tty]
Type
--bool value is "true" or "false"
--int value is decimal number
--bool-or-int value is --bool or --int
--path value is a path (file or directory name)
Other
-z, --null terminate values with NUL byte
--includes respect include directives on lookup
Git默认添加的配置的作用域是global
,也就是说用户没有在指定的项目下设置local
的Git配置时,就会使用作用域为global
的Git配置。
下面以local
作用域列举常用用法。
添加一个变量
git config --local --add user.name kitty
删除一个变量
git config --local --unset user.name