Mastodon

Opinionated, limited reference of interesting git config options and how I use them.

Interesting options

Ordered by usefulness.

  • rebase.autosquash true - when doing rebase --interactive, reorder commits created with commit --squash and commit --fixup.
  • push.autoSetupRemote true - create a remote branch when calling git push on a new local branch. Avoids the need for git push --set-upstream origin $BRANCH_NAME
  • fetch.prune true - implicit --prune in git fetch and git pull
  • diff.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 changes
  • init.defaultBranch main - the modern default
  • branch.sort committerdate - ensures that git branch output has the branch with newest commits at the bottom. Neat.
  • log.follow true - implicit --follow: when calling git log with 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 file
  • commit.verbose true - include the whole diff in git commit editor for reference
  • merge.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 plaintext
  • diff.algorithm histogram - reportedly better diff algorithm. I haven’t noticed a differnece yet
  • diff.mnemonicPrefix - not very important. Changes diff header to indicate commit/working tree sides instead of A/B.
  • diff.dirstat lines - include moved lines in the git log --dirstat/git diff --dirstat output. I don’t use --dirstat that 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 to false, 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. in git pull. Currently false for 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