天天看點

Git 筆記 - 01 Git Config 1. 簡述

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:

  1. /etc/gitconfig

     file: Contains values applied to every user on the system and all their repositories. If you pass the option 

    --system

     to 

    git 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.)
  2. ~/.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.
  3. 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 [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