Opinionated, limited reference of interesting git config options and how I use them.
Interesting options
Ordered by usefulness.
rebase.autosquash true- when doingrebase --interactive, reorder commits created withcommit --squashandcommit --fixup.push.autoSetupRemote true- create a remote branch when callinggit pushon a new local branch. Avoids the need forgit push --set-upstream origin $BRANCH_NAMEfetch.prune true- implicit--pruneingit fetchandgit pulldiff.interHunkContext 10- merge diffs which are close to each other. Nice quality of life improvement.diff.colorMoved true- different colors for lines which have been moved without changesinit.defaultBranch main- the modern defaultbranch.sort committerdate- ensures thatgit branchoutput has the branch with newest commits at the bottom. Neat.log.follow true- implicit--follow: when callinggit logwith a single path, always follow file renames.log.date local- display local dates instead of the original time zone.core.excludesFile $path- set path to a global gitignore filecommit.verbose true- include the whole diff in git commit editor for referencemerge.conflictstyle diff3- include the original text in addition to the 2 new variants. I was excited about this option at first but in practice I use the Visual Studio Code merge editor so the git config barely matters.diff.lockb.textconv bun,diff.lockb.binary true- needed to show Bun lock file as plaintextdiff.algorithm histogram- reportedly better diff algorithm. I haven’t noticed a differnece yetdiff.mnemonicPrefix- not very important. Changes diff header to indicate commit/working tree sides instead of A/B.diff.dirstat lines- include moved lines in thegit log --dirstat/git diff --dirstatoutput. I don’t use--dirstatthat much so not very important.
Currently unused
rerere.enabled true- record and reuse conflict resolution during rebase, in case of rebasing the same commits again. I have it set tofalse, if I’m rebasing again it likely means I did not do the previous conflict resolution correctly.submodule.recurse true- recurse into submodules automatically, e.g. ingit pull. Currentlyfalsefor me, because I don’t use submodules much nowadays, and I have shell aliases for the recursive command variants (e.g.git pull --recurse-submodules)
My current config
(parts of) my ~/.gitconfig:
[rebase]
autosquash = true
[rerere]
enabled = false
[submodule]
recurse = false
[push]
autoSetupRemote = true
[core]
autocrlf = input
[init]
defaultBranch = main
[diff]
algorithm = histogram
mnemonicPrefix = true
interHunkContext = 10
dirstat = lines
colorMoved = true
[merge]
conflictstyle = diff3
[branch]
sort = committerdate
[log]
follow = true
date = local
[diff "lockb"]
textconv = bun
binary = true
[commit]
verbose = 1
[fetch]
prune = true
Sources
- Popular git config options by Julia Evans - most of my recent additions to the config were inspired by this blog post
- Git documentation
- various
manpages for git subcommands