git 常用命令 - git config
git config 用来设置 git 的配置选项.
git 的配置文件分为三个层次:
- 系统层面, 适用于系统的所有用户和所有 git repo, 一般位于 /etc/gitconfig. 但是我的 git 是 xcode 自带的 git, 它的系统层面的配置文件就位于 /Applications/Xcode.app/Contents/Developer/usr/etc/gitconfig;
- 用户层面, 适用于当前用户的所有 git repo, 位于 ~/.gitconfig;
- repo 层面, 仅适用于当前 git repo. 一般位于当前 repo 的 .git/config.
git 的配置选项一般分成2类: 客户端起作用的配置和服务器端起作用的配置, 但绝大多数是客户端起作用的.
git 列出当前所有的配置:
git config --list (如果在某 repo, 则显示当前 repo 继承的, 否则显示当前用户层面的)
git config --global --list
git config --system --list
得到某一具体配置:
git config --get user.name
git config --global --get user.name
git config --system --get user.name
添加某一配置:
git config --global test.example example
git config --system --add test.sample "sample value"
去掉某一配置:
git config --global --unset test.example.value
git 常见的配置
git config 完全参考