git config 命令用于查看或者設(shè)置 git 倉(cāng)庫(kù)的配置信息。
git config [<file-option>] [--type=<type>] [--show-origin] [-z|--null] name [value [value_regex]]
git config 命令的選項(xiàng)比較多,我們著重介紹常用的配置命令。
# 查看全部配置信息 git config --list --global # 或者 git config -l --global
# 查看 user.name 配置信息 git config --global user.name # 查看 user.email 配置信息 git config --global user.email
參數(shù)說(shuō)明:
其中 --global 是作用域參數(shù)。還有 --local 和 --system。
--local 只對(duì)單個(gè)倉(cāng)庫(kù)有效。--system 對(duì)系統(tǒng)所有登錄用戶所有的倉(cāng)庫(kù)有效【很少用到】。--global 對(duì)當(dāng)前用戶所有的倉(cāng)庫(kù)有效【經(jīng)常用到】。
如果不加作用域參數(shù),默認(rèn)是 --local。
如果 global 和 local 都配置了,那么當(dāng)前倉(cāng)庫(kù)用的是 local 配置。
設(shè)置配置項(xiàng)的語(yǔ)法格式:
git config [--local|--global|--system] --unset section.key
范例:設(shè)置用戶名稱和用戶郵箱。
git config --global user.name 'your username' git config --global user.email 'your email address'
刪除配置項(xiàng)的語(yǔ)法格式:
git config [--local|--global|--system] --unset section.key
范例:刪除用戶郵箱。
git config --global --unset user.email 'your email address'