‹ jan0sch.de

Git - Template for .gitconfig

2018-07-17

Because there are way to many options for git to remember it is feasible to have a template file for the .gitconfig which is usually located in the home directory.

[user]
  name = John Doe
  email = john.doe@example.com
  signingkey = 0xAAAAAAAAAAAAAAAAAA
[alias]
  ci = commit
  co = checkout
  lg = log --graph --pretty=format:'%C(red)%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(blue)<%an>%Creset' --abbrev-commit --date=relative
  me = merge
  mom = merge origin/master
  mum = merge upstream/master
  st = status -sb
[color]
  branch = auto
  diff = auto
  interactive = auto
  pager = true
  status = auto
  ui = true
[color "status"]
  added = green
  changed = yellow
  untracked = red
[core]
  autocrlf = input
  pager = less -FRSX
  commentchar = $
  editor = nvr --remote-tab-wait +'set bufhidden=wipe'
[push]
  default = current
  followTags = true
[rebase]
  autostash = true
[tag]
  sort = version:refname

Some notes

The commentchar = $ option sets the character for comment lines to $ which is nice if your commit messages may start with an issue reference like #TicketNumber that would be ignored because # is the default comment character.

Another handy flag is the rebase.autostash = true setting which will automatically stash your local changes if you’re executing a rebase.

You might want to change the core.editor setting because that is set to use neovim-remote.