Git and libgit2
Mike Slinn

Global Git Configuration

Published 2023-05-30.
Time to read: 1 minutes.

This page is part of the git collection, categorized under Git.

This article is not meant to be exhaustive. These are just my notes about global settings that I use.

Global Configuration File

~/.gitconfig contains an OS user’s global settings. These settings are normally maintained by using the git config ‑‑global command, but the file could also be modified using a text editor.

[branch "master"]
  remote = origin
  merge = refs/heads/master
  filemode = false
  autocrlf = input
  safecrlf = false
  pager = less -F
  status = auto
  branch = auto
  ui = auto
  trustmtime = true
  default = matching
  autoSetupRemote = true
  autoSetupRemote = true
  name = Mike Slinn
  email =
  autostash = true
[diff "exif"]
  textconv = exiftool
  compactionHeuristic = true
  colorMoved = zebra
  defaultBranch = master
  rebase = true
  prune = true

Config Commands

The following commands created some of the above settings.

$ git config --global pull.rebase true

$ git config --global fetch.prune true

$ git config --global diff.colorMoved zebra

For an explanation of the above settings, please see Three Git Configurations that Should Be the Default.

$ git config --global rebase.autostash true

For an explanation of the above setting, please see this git tip by Chi Shang Cheng.

For an explanation of the core.pager setting, please see The Git Pager.

Environment Variables

If you do not want to type merge comments, you can either use the --noedit option each time you run git merge, like this:

$ git merge --no-edit

Or you can define a bash alias, like this:

alias git.merge='git merge --no-edit'

Or you can add the following to ~/.bashrc: