命令参数
--get
获取指定的配置项。
--global
--local
-l, --list
列出配置文件中的所有配置项。
配置文件
如果没有显示地指定 --file 选项,则有 4 个文件供 git 配置查询配置项。
$(prefix)/etc/gitconfig
全系统的配置文件
~/.gitconfig
用户特定的配置文件,也称为全局配置文件。
$XDG_CONFIG_HOME/git/config
用户特定的次要的配置文件。如果 $XDG_CONFIG_HOME 没有设置或者为空,$HOME/.config/git/config 会被替代。
$GIT_DIR/config
仓库特定的配置文件。
实例
a) 设置用户名与用户邮件 ID
$ git config --global user.name "huey" $ git config --global user.email "huey@example.com"
b) 设置颜色高亮
$ git config --global color.ui true
c) 列出当前的配置选项
$ git config --list