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.

~/.gitconfig
[branch "master"]
  remote = origin
  merge = refs/heads/master
[core]
  filemode = false
  autocrlf = input
  safecrlf = false
  pager = less -F
[color]
  status = auto
  branch = auto
  ui = auto
[gui]
  trustmtime = true
[push]
  default = matching
  autoSetupRemote = true
  autoSetupRemote = true
[user]
  name = Mike Slinn
  email = mslinn@mslinn.com
[rebase]
  autostash = true
[diff "exif"]
  textconv = exiftool
[diff]
  compactionHeuristic = true
  colorMoved = zebra
[init]
  defaultBranch = master
[pull]
  rebase = true
[fetch]
  prune = true

Config Commands

The following commands created some of the above settings.

Shell
$ 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.

Shell
$ 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:

Shell
$ git merge --no-edit

Or you can define a bash alias, like this:

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

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

~/.bashrc
export GIT_MERGE_AUTOEDIT=no