在git中,我们使用git config 命令用来配置git的配置文件,git配置级别主要有以下3类:
1、仓库级别 local 【优先级最高】
2、用户级别 global【优先级次之】
3、系统级别 system【优先级最低】
配置文件生效生效优先级是先项目(.git/config),后用户(~/.gitconfig),最后系统(/etc/gitconfig)。由于git的使用都是以用户级的,所以我们日常用的最多都是通过用户级别的配置。
常用命令:
- 初始化配置参数
git config --global user.name 'your username'
git config --global user.email 'your email address'
- 查看配置结果
git config --list --global
// or
git config -l --global
// or 查看 user.name 配置信息
git config --global user.name
// or 查看 user.email 配置信息
git config --global user.email
参数说明:
其中 --global 是作用域参数。还有 --local 和 --system。
–local 只对单个仓库有效。–system 对系统所有登录用户所有的仓库有效【很少用到】。–global 对当前用户所有的仓库有效【经常用到】。
如果不加作用域参数,默认是 --local。
如果 global 和 local 都配置了,那么当前仓库用的是 local 配置。