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:
-
file: Contains values applied to every user on the system and all their repositories. If you pass the option/etc/gitconfig
to--system
, 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.)git config
-
or~/.gitconfig
file: Values specific personally to you, the user. You can make Git read and write to this file specifically by passing the~/.config/git/config
option.--global
-
file in the Git directory (that is,config
) of whatever repository you’re currently using: Specific to that single repository..git/config
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 [email protected]
$ git config --global user.name "John Doe"
$ git config user.name "John Doe"
$ git config user.email [email protected]
3. 顯示中文,防止出現亂碼
git config --global core.quotepath false
原文位址:https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup
1.6 Getting Started - First-Time Git Setup