‹ jan0sch.de

Git - Template for .gitconfig


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.

  name = John Doe
  email = john.doe@example.com
  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
  branch = auto
  diff = auto
  interactive = auto
  pager = true
  status = auto
  ui = true
[color "status"]
  added = green
  changed = yellow
  untracked = red
  autocrlf = input
  pager = less -FRSX
  commentchar = $
  editor = nvr --remote-tab-wait +'set bufhidden=wipe'
  default = current
  followTags = true
  autostash = true
  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.