三個不同的位置:
1./etc/gitconfig 檔案:包含了适用于系統所有使用者和所有庫的值。如果你傳遞參數選項’--system’ 給 git config,它将明确的讀和寫這個檔案。
2.~/.gitconfig 檔案 :具體到你的使用者。你可以通過傳遞--global 選項使Git 讀或寫這個特定的檔案。
3.位于git目錄的config檔案 (也就是 .git/config) :無論你目前在用的庫是什麼,特定指向該單一的庫。每個級别重寫前一個級别的值。是以,在.git/config中的值覆寫了在/etc/gitconfig中的同一個值。
常用配置及别名習慣:
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = /Users/andy/.gitignore_global
# 送出時, 不允許混合不同的換行符
safecrlf = true
# 檢出和送出時, 都不自動轉換換行符
autocrlf = false
[web]
browser = google-chrome
[rerere]
enabled = 1
autoupdate = 1
[alias]
s = status
st = status
sb = status -s -b
#############
d = diff
di = diff
dc = diff --cached
dk = diff --check
dck = diff --cached --check
#############
c = commit
ca = commit -a
cm = commit -m
ci = commit
#############
l = log --oneline
lg = log --oneline --graph --decorate
#############
o = checkout
co = checkout
ob = checkout -b
cob = checkout -b
#############
b = branch
bv = branch -vv
ba = branch -a
bd = branch -d
br = branch -r
#############
f = fetch
fo = fetch origin
#############
m = merge
#############
ps = push
pl = pull
pb = pull --rebase
psf = push -f
psu = push -u
plu = pull -u
pso = push origin
plo = pull origin
pbo = pull --rebase origin
psfo = push -f origin
psuo = push -u origin
pluo = pull -u origin
#############
rb = rebase
#############
re = reset
rh = reset HEAD
reh = reset --hard
rem = reset --mixed
res = reset --soft
rehh = reset --hard HEAD
remh = reset --mixed HEAD
resh = reset --soft HEAD
#############
w = show
#############
human = name-rev --name-only --refs=refs/heads/*
[color]
ui = true
[color "branch"]
current = yellow bold
local = green bold
remote = cyan bold
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
whitespace = red reverse
[color "status"]
added = green bold
changed = yellow bold
untracked = red bold
[push]
default = upstream
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
[filter "media"]
required = true
clean = git media clean %f
smudge = git media smudge %f
[filter "hawser"]
clean = git hawser clean %f
smudge = git hawser smudge %f
required = true