Skip to content

Instantly share code, notes, and snippets.

@capnslipp
Last active January 31, 2023 16:17
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save capnslipp/859701 to your computer and use it in GitHub Desktop.
Save capnslipp/859701 to your computer and use it in GitHub Desktop.
my global .gitconfig file(s), with tweaks for: command verbosity, more-distinct colors, and handy aliases
# Base
[core]
excludesfile = /Users/capnslipp/.git_excludes
attributesfile = /Users/capnslipp/.git_attributes
#editor = mate -w
editor = macdown-wait
whitespace = tabwidth=4, space-before-tab, indent-with-non-tab, blank-at-eol, blank-at-eof
# defaults: whitespace = blank-at-eol, space-before-tab, -indent-with-non-tab, -tab-in-indent, blank-at-eof, trailing-space, -cr-at-eol, tabwidth=8
quotepath = false
# the following are so that repositories on shared filesystems can omit this setting and obey their own OS's conventions
ignorecase = true # (true: the default for new repos on Mac OS X)
precomposeunicode = false # (false: the default for new repos on Mac OS X)
commentChar = ">"
[sequence]
#editor = subl --wait
editor = mate --wait --recent
[push]
default = upstream
[branch]
# I really like `branch.autosetuprebase = remote` set, but it's probably best set in a repo template than here to avoid confusion when working with others who don't (initially) have it set.
[user]
name = Slipp Douglas Thompson
email = try a dot-“com”, preceded by a “capnslipp”, and an “at” ahead of that, and last but first “git”
[credential]
helper = osxkeychain
[init]
templatedir = /Users/capnslipp/usr/share/git-core/templates/default
[commit]
cleanup = verbatim # Don't scrub trailing whitespace!  GitHub-Flavored Markdown commits need trailing two-spaces on some lines to enforce line breaks.
status = false # We don't really need the status messages in the commit— that's what `git status` and tools like GitX are for.  This speeds up presentation of the commit editor noticeably, too.
# SVN
# AFAIK, there is no way to have non-specified authors left as-is, therefore, this setting is probably best set per-repository, unless one deals with a lot of SVN repos from the same group of authors.
[svn]
authorsfile = /Users/capnslipp/".git-svn_authors"
[svn-remote]
placeholder-filename = '.git-emptydir'
# Tools/Subcommands
[diff]
algorithm = patience # histogram has been creating a lot of “misaligned” diffs for me, especially for C-style functions with similar endings (e.g. `return self;`)
context = 3 # default: 3
renames = copies
submodule = log
#suppressBlankEmpty = true # seems to fuck with GitX's diff views
tool = opendiff
mnemonicprefix = true
[diff "xibition"]
textconv = xibition
cachetextconv = true
xfuncname = "^(@interface[ \t].*)$\n^[0-9 |-]*----\\+ (.+)$"
[diff "swift"]
xfuncname = "^.*((class|extension|struct|protocol).*)$" # doesn't seem to be working currently
[difftool]
prompt = true
[difftool "sourcetree"]
cmd = "opendiff \"$LOCAL\" \"$REMOTE\""
trustExitCode = true
path =
[difftool "p4merge"]
cmd = "p4merge \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\""
keepTemporaries = false
trustExitCode = false
keepBackup = false
[difftool "meld"]
prompt = false
[merge]
#ff = false # In most cases, a FF is not what I want when I say “merge”, and FF can still be achieved with a `merge --ff` or `merge --ff-only`.
# This, however, has the side-effect of causing `git pull --ff-only` to fail with a `fatal: You cannot combine --no-ff with --ff-only.`.
# This should, however, be a non-issue if `branch.<name>.rebase`s are set to `true`, which should always be the case when `branch.autosetuprebase = remote` is set.
[mergetool "sourcetree"]
cmd = "/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\""
trustExitCode = true
[rebase]
stat = true
autosquash = true
[log]
#decorate = full
[grep]
extendedRegexp = true
lineNumber = true
[format]
pretty = fuller
[fetch]
recurseSubmodules = true # on-demand (the default) may be better for this option; revert if this causes issues rather than helping
[status]
submodulesummary = true
# Handy Variants/Macros
[alias]
diff = diff --compaction-heuristic
log = log --no-expand-tabs
lg = !"git lg1"
lg1 = !"git lg1-specific --all"
lg2 = !"git lg2-specific --all"
lg3 = !"git lg3-specific --all"
lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) %C(cyan)%aD%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)%n'' %C(cyan)%aD%C(reset) %C(green)(%ar)%C(reset)'
lg3-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) %C(white)%s%C(reset)%C(auto)%d%C(reset)%n'' %C(cyan)%aD%C(reset) %C(green)(%ar)%C(reset) %C(cyan)(committed: %cD)%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
show1 = show --no-patch --decorate --format=format:'%C(bold blue)%h%C(reset) %C(green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
show2 = show --no-patch --decorate --format=format:'%C(bold blue)%h%C(reset) %C(cyan)%aD%C(reset) %C(green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
show3 = show --no-patch --decorate --format=format:'%C(bold blue)%h%C(reset) %C(white)%s%C(reset)%n'' %C(cyan)%aD%C(reset) %C(green)(%ar)%C(reset) %C(cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
tail = rev-list --max-parents=0 HEAD
log-current-branch = !"git log --oneline --no-merges $(git rev-parse --abbrev-ref HEAD) --not $(git for-each-ref --format=\"%(refname)\" refs/heads | grep -Fv refs/heads/$(git rev-parse --abbrev-ref HEAD))"
snatch = cherry-pick # a more fitting name, considering how sexy cherry-pick is (and is easier to type)
word-diff = diff --minimal --word-diff=plain
char-diff = diff --minimal --word-diff-regex='.'
show-author = show -s --format='%an <%ae>'
show-author-date = show -s --format='%ad'
show-committer = show -s --format='%cn <%ce>'
show-committer-date = show -s --format='%cd'
graphviz = !"f() { echo 'digraph git {\n node [shape=box,fillcolor=\"#33ccff77\",color=\"#33ccff77\",style=filled];\n' ; git log --pretty='format: %h -> { %p };%n %h -> tags_%h [style=invis];%n tags_%h [shape=plaintext,fillcolor=transparent,label=\"%d\"];%n {rank=same; %h; tags_%h}' | gsed 's/\\(tags_\\)\\?[0-9a-f]\\{7,\\}/\"&\"/g' ; echo '}'; }; f" # from: https://git.wiki.kernel.org/index.php/Aliases#Use_graphviz_for_display
# Colors
# I found myself occasionally confused by the command-line colorings, so I tweaked the colors and styles so they're more distinct and so that certain colors are only used for specific purposes.
# @note: YMMV; I use terminal colorings of white text on black background (with distinct shades of gray for black/dark-gray ('0;30m'), bright-black/mid-gray ('1;30m'), and non-bright-white/light-gray ('0;37m')).
[color]
ui = auto # Git w/o any color is cruel and unusual punishment
[color "branch"]
current = bold reverse red
local = reverse green
remote = reverse cyan
plain = reverse white
[color "diff"]
plain = white
meta = bold blue black
frag = bold yellow black
func = cyan
old = red
new = green
commit = bold black # Affects git-log auto-decorate-colored ref names.  Weird.
whitespace = reverse black
[color "decorate"]
branch = bold green black # default: bold green
remoteBranch = bold blue black # default: bold red
tag = bold yellow black # default: bold yellow
stash = bold yellow black # default: bold magenta
HEAD = bold red black # default: bold cyan
[color "status"]
header = dim white black
updated = bold yellow # AKA added
changed = bold magenta
untracked = bold cyan
unmerged = bold blue
nobranch = bold reverse blink red
*~
*.orig
*.rej
*.swp
.#*
*.obj
*.o
.DS_Store
# for git-svn
.git-emptydir
## Customized default git repo template, stored at ~/usr/share/git-core/templates/default/
# Base
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
# removed: ignorecase = true (I believe this should be set on a global or system level, not per-repo.  I assume it's in here by default as a half-ass hack for grandfathering old repos while making new repos modernized— what should probably be bump of the repositoryformatversion.)
# removed: precomposeunicode (ditto)
[merge]
ff = false
[branch]
autosetuprebase = remote
[receive]
denycurrentbranch = warn
# Remotes
# Branches
# newly-added settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment