Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

git

Stow package for ~/.gitconfig.

Table of contents

Layout

FileStows to
git/.gitconfig~/.gitconfig

Local / private overrides

The tracked .gitconfig ends with:

[include]
  path = ~/.gitconfig.local

Anything machine-specific or sensitive (work email, signing keys, work remotes, credential helpers) lives in ~/.gitconfig.local, which is not stowed and not in the repo. Create it by hand per machine.

For example, gh auth setup-git writes a [credential] helper with a host-specific path (/opt/homebrew/bin/gh on macOS) — that belongs here, not in the tracked .gitconfig.

Delta integration

git-delta is wired in as the pager for git diff, show, log, blame:

[core]
  pager = delta
[interactive]
  diffFilter = delta --color-only
[delta]
  navigate = true        # n / N jumps between hunks
  side-by-side = true    # split view (drop for narrow terminals)
  line-numbers = true
[merge]
  conflictstyle = zdiff3 # better 3-way conflict markers; needs git ≥ 2.35

brew install git-delta provides the binary (already in the Brewfile).

Behavior tuning

[init]    defaultBranch = main
[pull]    rebase = true; ff = only             # rebase on pull, error on divergence
[push]    default = current; autoSetupRemote = true; followTags = true
[fetch]   prune = true                          # drop refs to deleted remote branches
[rebase]  autosquash = true; autoStash = true   # fixup! commits flow; uncommitted work stashes
[diff]    algorithm = histogram; colorMoved = default; renames = copies
[rerere]  enabled = true                        # remember conflict resolutions

These set sane defaults for git’s nagging warnings (divergent branches, missing upstream) and unlock features that aren’t on by default but should be (rerere, histogram diff, move-block detection).

Aliases

AliasExpands toUse
git ststatus -sbshort status with branch line
git cocheckout
git brbranch
git cmcommit
git cacommit --amend
git canecommit --amend --no-editamend without re-editing the message
git lgpretty-graph logone-line graph with colors and ago-style dates
git lastlog -1 HEAD --statwhat did the last commit touch?
git stageddiff --cachedreview what’s about to be committed
git unstagereset HEAD --undo git add
git undoreset --soft HEAD^un-commit (keeping changes)
git wipadd -A && commit -m 'WIP'snapshot to step away
git prune-branchesdelete every merged branch (except current / main / master)safe local cleanup
git cpcherry-pick
git sw / git swcswitch / switch -cmodern branch switch / create
git cobcheckout -bcreate + switch (older style)
git aa / git apadd -A / add -pstage all / interactively by hunk
git fafetch --all --prunerefresh all remotes, drop stale branches
git pfpush --force-with-leasesafe force-push (won’t clobber others’ work)
git rbirebase -i --autosquashinteractive rebase, auto-orders fixups
git rbc / git rbarebase --continue / --abort
git fixupcommit --fixup <sha>marks a fixup commit for rbi to squash
git recentlast 10 branches by commit date
git rootrev-parse --show-toplevelprint the repo root
git aliaseslist every configured alias

Dracula color scheme

The [color "*"] sections set a Dracula-inspired palette for branches, diffs, grep, interactive prompts, and status. Most slots are explicit; empty values mean “use the default.”

URL aliases

[url "https://github.com/dracula/"]
  insteadOf = dracula://

Lets you git clone dracula://vim instead of typing the full URL.

Companion tools

Installed via Brewfile, no extra config required:

ToolUse
git-deltapager (wired in above)
git-absorbgit absorb — auto-creates fixup! commits targeting the right earlier commit based on what lines your unstaged changes touch. Pair with git rebase -i --autosquash (which [rebase] autosquash = true runs by default).
git-branchlessadds porcelain inspired by Mercurial/Sapling: git smartlog, git move, git restack, git undo (cross-operation undo). Power-user; read git help branchless first.

Fresh-machine setup

stow git

Create ~/.gitconfig.local for any per-machine bits (work email, signing keys, etc.) that shouldn’t live in the repo. git-delta, git-absorb, and git-branchless come in via the Brewfile.