Git的全局配置文件位于用户主目录中:
~/.gitconfig
.gitconfig
文件使用INI
格式,每个部分都有一个部分名称和对应的键值对。
[user]
name = Your Name
email = your.email@example.com
[alias]
co = checkout
br = branch
ci = commit
st = status
[color]
ui = auto
[core]
editor = vim
fileMode = false
[user]
name = Your Name
email = your.email@example.com
别名可以简化常用Git命令的输入。
[alias]
co = checkout
br = branch
ci = commit
st = status
last = log -1 HEAD
启用颜色以提高可读性。
[color]
ui = auto
在某些系统上,文件权限变化可能会影响Git的行为。
[core]
fileMode = false
自定义日志输出格式。
[format]
pretty = format:%C(auto)%h%d%Creset %s %C(blue)%an%Creset %C(dim)%ar%Creset
配置差异工具以更方便地查看文件差异。
[diff]
tool = meld
[difftool "meld"]
cmd = meld "$LOCAL" "$REMOTE"
配置合并工具以更方便地解决冲突。
[merge]
tool = meld
[mergetool "meld"]
cmd = meld "$LOCAL" "$BASE" "$REMOTE" --output "$MERGED"