一、配置文件级别
Git 使用简单的 .ini 文件作为配置文件,配置文件中记录了很多 Git 命令使用的各种选项和设置,Git 支持不同级别的配置文件,下面按照优先级从高到低的顺序对它们进行介绍:
.git/config 当前版本库特定的配置文件,可使用 --file选项修改,是Git的默认选项,此文件中的设置具有最高优先级。
~/.gitconfig 当前用户的配置文件,可使用 --global选项修改。
/etc/gitconfig 系统级别的配置文件,可使用 --system 选项修改,此文件中的设置优先级最低。
二、配置选项
git config --file user.name "sean"
git config --file user.email "sean@example.com"
git config --global user.name "sean"
git config --global user.email "sean@example.com"
git config --system user.name "sean"
git config --system user.email "sean@example.com"
三、移除配置
使用 git config -l 命令可列出在配置文件中配置的所有项。
git config --unset 可移除配置文件中的配置,使用方法如下:
git config --unset user.name
git config --unset --global user.name
git config --unset --system user.name