概述
该命令,用于配置git。
配置文件
三个配置文件,可以手动编辑配置,也可以使用 git config 命令修改
- .git/config 文件,作用于当前目录,优先级第一
- ~/.gitconfig 文件,作用于特定用户,优先级第二
- 安装目录/etc/gitconfig 文件,作用于当前 git 安装,优先级最后
配置文件的语法格式:
- 注释使用分号
- 配置项 8 个空格,例如
; 别名配置
[alias]
st = status
co = checkout
br = branch
ci = commit
; 用户名称配置
[user]
name = wuqiyin
email = silverwq@qq.com
; http代理配置
[http]
proxy = socks5://127.0.0.1:1080
[https]
proxy = socks5://127.0.0.1:1080
命令
git config --list 或者 git config -l,
# 默认是--local级别
git config [--system|--global|--local] -l
git config --list
# 查看具体的某个配置
git config user.name
git config --add
# 默认是--local级别
git config [--system|--global|--local] --add user.name wuqiyin
git config -e
# 默认是--local级别
git config [--system|--global|--local] -e
git config --unset
# 默认是--local级别
git config [--system|--global|--local] --unset user.name