1. 简述
Git comes with a tool called git config
that lets you get and set configuration variables that control all aspects of how Git looks and operates. These variables can be stored in three different places:
-
/etc/gitconfig
file: Contains values applied to every user on the system and all their repositories. If you pass the option--system
togit config
, it reads and writes from this file specifically. (Because this is a system configuration file, you would need administrative or superuser privilege to make changes to it.) -
~/.gitconfig
or~/.config/git/config
file: Values specific personally to you, the user. You can make Git read and write to this file specifically by passing the--global
option. -
config
file in the Git directory (that is,.git/config
) of whatever repository you’re currently using: Specific to that single repository.
Each level overrides values in the previous level, so values in .git/config
trump those in /etc/gitconfig
.
2. 变量
git config --list
查看所有的配置信息
2.1 Identity
读取/写入
$ git config --global user.email johndoe@example.com
$ git config --global user.name "John Doe"
$ git config user.name "John Doe"
$ git config user.email johndoe@example.com
3. 显示中文,防止出现乱码
git config --global core.quotepath false
原文地址:https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup