What should go in a default git config file?

shemnon picture shemnon · Jun 29, 2011 · Viewed 12.5k times · Source

There is a bewildering array of options that can be set via git config, and that is just the documented ones. Of all of these options, which ones should every developer have set on their box (like user.email)? And what are the most common ones that should be set in common situations (like core.autocrlf=input on Windows)? But please stay away from religious arguments (like the only acceptable setting of core.whitespace being tab-in-indent).

Answer

Guildencrantz picture Guildencrantz · Jun 29, 2011

Your global git config (~/.gitconfig) should really contain the settings that apply to ALL your repositories. Primarily things like user.name, user.email, core.editor, merge, and diff should be pretty consistently set. That being said I also like to enable color, core.pager, rerere, rebase.autosquash and a slew of aliases.

[color]
    filemode = false
    diff = auto
    status = auto
    branch = auto
    pager = true
[alias]
    b = branch
    ci = commit
    co = checkout
    cob = checkout -b
    d = diff
    l = log
    lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
    lga = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --branches
    st = status
    fixup = !sh -c 'git commit -a -m \"fixup! $(git log -1 --format='%s' $@)\"' -
    squash = !sh -c 'git commit -a -m \"squash! $(git log -1 --format='%s' $@)\"' -
    ri = rebase --interactive
    rc = rebase --continue
    pr = push gerrit HEAD:refs/for/master
    mt = mergetool
[user]
    email = REDACTED
    name = Matt Henkel
[core]
    pager = less -FRSX
    excludes = ~/.gitexcludes
    editor = vim
[rerere]
    enabled = true
    autoupdate = true
[rebase]
    autosquash = true
[merge]
    tool = kdiff3
[mergetool "kdiff3"]
    keepBackup = false
    trustExitCode = false
[diff]
    tool = kdiff3