摘要
之前介紹過一篇如何在Linux環(huán)境下部署Git Server服務。具體詳見如何在Linux上搭建一個Git中央倉庫
在部署安裝之后痢毒。這里有一些必須的配置和優(yōu)化性質(zhì)的配置
配置分類介紹
這里的配置介紹已Linux
為標準介紹涝开,Windows或者Mac請自行根據(jù)后續(xù)方式嘗試
-
/etc/gitconfig
系統(tǒng)級別的Git配置腿椎,作用于系統(tǒng)所有用戶系宜。
-
~/.gitconfig
全局作用域Git配置,全局作用于當前系統(tǒng)用戶(推薦配置)
-
project/.git/config
針對當前項目的Git配置舌仍,一般clone項目之后,存在于項目目錄下通危。
git config
可以通過如下命令來查看具體用法(適用Linux/Unix/Mac系統(tǒng))
git config --help
通過查找我們知道git config --global
來配置上面介紹的~/.gitconfig
铸豁,類似的有git config --system
和 git config --local
(default)
或者我們可以通過如下命令反查參數(shù)對應的配置文件的具體路徑。配置文件的路徑提示在編輯模式的窗口下面
菊碟。不同系統(tǒng)配置略有不同
git config -e [--system|--global|--local]
列舉和查看 配置
# 列出已有的配置信息(重復的變量名表示來自不同的配置文件).
git config --list
# 得到具體配置
git config --get user.name
git ocnfig user.name
配置用戶信息
git config --global user.name "colin"
git config --global user.email colin@126.com
配置顏色相關
# 在Git命令輸出中開啟顏色顯示.
git config --global color.ui true
配置別名 alias
git config --global alias.st status
git config --global alias.ad "add"
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.lg 'log --date=local
--pretty=format:"%n%C(yellow)%h%Creset| %C(yellow)%cd %Creset| %C(yellow)%cn%n%C(green)%s"'
其他配置
# 解決工作目錄中文顯示的問題.
git config --global core.quotepath false
# windows平臺建議禁止Git對文件權限的跟蹤.
git config --global core.fileMode false
# git 默認編輯器
git config --global core.editor /usr/bin/vim
git config -e [--global]
# 打開[global]級配置文件進行編輯.
刪除配置
# 刪除指定變量配置.
git config --global unzet key