git修改用戶名和郵箱

問題

進入新公司用的是上一個開發在使用的電腦,git 提交時顯示的他的用戶名和郵箱因此想改下。git

概述:

git 能夠設置系統的配置文件(用戶名和郵箱),也能夠設置全局的配置文件(用戶名和郵箱),以及爲倉庫單獨設置配置文件(用戶名郵箱)。「我目前公司使用的電腦裏面的項目就是使用倉庫單獨設置的,開始我修改了全局的,但在提交後發現仍是沒有變,非常奇怪,最後發現還能夠爲倉庫單獨設置。」bash

查看用戶名和郵箱
git config --[system][global][local] user.name
git config --[system][global][local] user.email

//這裏以查看 system 爲例
git config --system user.name
複製代碼
修改用戶名和郵箱
git config --[system][global][local] user.name "your name"
git config --[system][global][local] user.email "your email"
複製代碼

這三者的區別和使用

這三者的配置文件的權重不一樣,local > global > system。在值發生衝突時,好比 local 定義了 user.name ,global 也定義了 user.name 。優先使用權重大的 local 中設置的值。ui

git 配置的其餘操做

查看配置文件
git config --[system][global][local] -[list][l]
//-list 能夠簡寫爲 -l
複製代碼
編輯配置文件
git config --[system][global][local] -[edit][e]
//-edit 能夠簡寫爲 -e
複製代碼
添加一個配置項
git config --[system][global][local] --add section.key value
//例子
git config --local --add my.name qinlei
複製代碼
獲取一個配置項
git config --[system][global][local] --get section.key
//以獲取上面的 my.name 爲例
git config --local --get my.name
複製代碼
相關文章
相關標籤/搜索