Git的三种配置文件:
- 1.版本库级配置文件: 项目工作区下,local
- 2.全局配置文件: 用户主目录下,global
- 3.系统级配置文件: /etc目录下,system
- 配置优先级:1 > 2 > 3
执行下面的一系列命令,打开对应的配置文件:
注: /home/workspace/demo 是项目工作区根目录
/home/workspace/demo$ git config -e [local]
/home/workspace/demo/.git/config
/home/workspace/demo$ git config -e --global
~/.gitconfig
git config -e --system
/usr/local/etc/gitconfig
配置文件采用的是INI文件格式, 示例如下:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
git config命令可以用于读取和更改INI配置文件的内容。
读取:git config <section>.<key>
更改:git config <section>.<key> <value>
示例:
读 git config core.filemode
写 git config a.b c
带上参数 --global,--system 读写对应的文件。
-- 内容出自《Git权威指南》