Konfigurationsschichten
Git liest Konfiguration aus mehreren Dateien in Reihenfolge: system, global (~/.gitconfig), local (.git/config), worktree und Befehlszeile (-c).
Bedingte Includes
[includeIf "gitdir:~/work/"]
path = ~/.gitconfig.work
[includeIf "gitdir:~/personal/"]
path = ~/.gitconfig.personal
[includeIf "onbranch:release/*"]
path = ~/.gitconfig.release
[includeIf "hasconfig:remote.*.url:[email protected]:work-org/**"]
path = ~/.gitconfig.work
Komponierende Aliase
[alias]
co = checkout
cm = commit -v
st = status -sb
lg = log --graph --pretty=format:'%C(auto)%h %ad %s %d' --date=short
last = log -1 HEAD --stat
unstage = reset HEAD --
sync = "!f() { git fetch --all --prune && git rebase --autostash @{u}; }; f"
publish = "!git push -u origin $(git symbolic-ref --short HEAD)"
URL-Umschreibung
[url "[email protected]:"]
insteadOf = https://github.com/
[url "https://github.com/"]
pushInsteadOf = [email protected]:
Konfiguration pro Worktree
git config extensions.worktreeConfig true
git config --worktree user.email [email protected]
Sinnvolle Standardwerte
[core]
autocrlf = input
fsmonitor = true
untrackedCache = true
[merge]
conflictStyle = zdiff3
ff = false
[pull]
rebase = true
[rebase]
autoSquash = true
autoStash = true
updateRefs = true
[push]
autoSetupRemote = true
default = current
[fetch]
prune = true
parallel = 0
[diff]
algorithm = histogram
colorMoved = default
submodule = log
[init]
defaultBranch = main
[advice]
detachedHead = false
[feature]
manyFiles = true
Inspektion
git config --list --show-origin
git config --get-all alias.lg
git config --show-scope user.email
git -c user.email=other@x commit -m "ad-hoc identity"
Haufige Fehler
Anmeldedaten in committeten Dateien setzen.