Git Configuration - uhop/dotfiles GitHub Wiki

Git Configuration

Core settings

Setting Value Purpose
core.pager delta Syntax-highlighting pager
core.editor micro Default editor
core.autocrlf input Convert CRLF→LF on commit, keep LF on checkout
core.whitespace trailing-space,-space-before-tab,cr-at-eol Whitespace error detection
interactive.diffFilter delta --color-only Interactive staging diffs
init.defaultBranch main Default branch name
pull.rebase false Merge on pull (no rebase)
push.autoSetupRemote true Auto-track remote on first push
remote "origin".prune true Auto-prune stale remote branches on fetch

Diff viewers

delta — line-based, syntax-highlighted (default)

Delta is wired into core.pager / interactive.diffFilter / pager.diff, so every git diff, git log -p, git show, git add -p etc. flows through it. Defaults:

  • Theme: Monokai Extended — shared with bat via ~/.config/bat/config so git diff and cat/bat render syntax identically. Preview alternatives with delta --list-syntax-themes or bat --list-themes.
  • Layout: inline (side-by-side off). Laptop-first; wide layout on demand.
  • navigate = true — press n/N in the pager to jump between hunks.
  • line-numbers = true — gutter with before/after line numbers.
  • diff.colorMoved = default — reformats moved-line blocks so they stand out from genuine edits.

The retained legacy [color "diff"] / [color "diff-highlight"] sections feed plain git diff when delta isn't available (failure fallback). Values:

  • Old lines: red bold, highlight on color 52
  • New lines: green bold, highlight on color 22
  • Meta: color 11 · Fragment headers: magenta bold · Function context: color 146 bold · Commit hash: yellow bold

Wide (side-by-side) layout on demand

Inline is the default because a 13″ / 14″ laptop panel runs out of columns for side-by-side. The [delta "wide"] named feature flips it on for a single invocation:

git dw                          # alias: wide `git diff`
git -c delta.features=wide show # ad-hoc wide on any command

difftastic — structural (AST) diff, on demand

Difftastic parses both sides into syntax trees and diffs the trees, so reformats, moves, and rearrangements show as the small edits they really are. Not wired into git diff — it's registered as a difftool:

git dft                         # alias: structural diff of unstaged changes
git dft --cached                # staged changes
git dft main..HEAD              # branch range

diff.tool = difftastic makes git difftool use it by default. Good fit for: big refactors, whitespace-only churn, auto-formatter passes, file moves. Not a pager replacement — line-based delta stays the workhorse.

Pretty formats

better-oneline

<hash> <decorations> <subject> (<relative date>) [<committer>]

Used by: ls, ll, lsf, tree

detailed-commit

Multi-line format showing commit hash (short + full), decorations, date (absolute + relative), author, subject, and body.

Used by: sl, last

Git aliases

Navigation and inspection

Alias Command Description
git ls log --oneline --pretty=better-oneline Compact log
git ll log --oneline --pretty=better-oneline --numstat Compact log + changed files
git lsf log --oneline --pretty=better-oneline --graph --follow Log with graph, follows renames
git tree log --oneline --pretty=better-oneline --all --graph Full branch graph
git sl log --graph --pretty=detailed-commit Detailed log with graph
git last log -1 --pretty=detailed-commit Last commit in detail
git aliases List all configured aliases

Branching

Alias Command Description
git trim Delete all local branches except main/master/current, prune origin Clean up old branches

Committing and pushing

Alias Command Description
git save add -A && commit -m 'chore: savepoint' Quick save-all commit
git force-push push --force-with-lease Safe force push
git patch --no-pager diff --no-color Plain-text patch output
git dw -c delta.features=wide diff Wide (side-by-side) diff via delta
git dft difftool Structural (AST) diff via difftastic
git precommit diff --cached --diff-algorithm=minimal -w Review staged changes (ignore whitespace)
git unmerged diff --name-only --diff-filter=U List unmerged files

Reset and clean

Alias Command Description

Merge inspection

Alias Description
git merge-span Helper: compute parent range of a merge commit
git merge-log Log of commits in a merge
git merge-diff Diff of a merge

Author statistics

Alias Description
git authors-list Authors sorted by commit count (with emails)
git authors-count Authors sorted by commit count (names only)

Custom git commands (in ~/.local/bin)

These are standalone scripts available as git <command>:

Command Description
git br Pretty branch list: name, subject, relative date, author
git brr Remote branches sorted by committer date
git bs Branch list in columnar format (date, author, branch, subject)
git mbs Filter git bs --all to show only your branches
git pull-main Auto-detect default branch, checkout, and pull
git super-clean Hard reset + deep clean (removes all untracked including ignored)

See Utilities — Git helpers for details.

Shell git aliases

Shell aliases (gst, gco, gpush, gsw, etc.) are defined in .bash_aliases and documented in Shell Environment § Git shell aliases. For workflow examples see Workflows: git.

GUI

  • Font: Hack Nerd Font Mono, size 14
  • Hub protocol: SSH
  • LFS: Enabled (clean, smudge, filter-process)

Work configuration

The [includeIf] directive loads ~/.gitconfig-work for repositories hosted under a specific GitHub organization. This allows separate name/email for work commits.

⚠️ **GitHub.com Fallback** ⚠️