Git Configuration

Git configuration with aliases, delta for diffs, and work/personal separation

Git configuration optimized for daily development with useful aliases, improved diff viewing, and separate configs for work and personal projects.

Features #

  • Delta - Syntax-highlighted diffs and pager
  • Conditional includes - Different configs for work vs personal
  • Useful aliases - Shortcuts for common operations
  • Bat integration - Better file viewing

Setup #

Installation #

Git is typically pre-installed. For latest version:

# Ubuntu/Debian
sudo apt install git

# Arch Linux
sudo pacman -S git

# Via mise
mise install git

Configuration #

Main config at ~/.gitconfig:

[user]
    name = Waylon S. Walker
    email = [email protected]
    signingkey = 66E2BF2B4190EFE4

[core]
    editor = nvim -c startinsert
    excludesfile = ~/.global-gitignore
    pager = bat --style=plain

Conditional Includes #

Different configurations for different directories:

[includeIf "gitdir:~/work/"]
    path = ~/.gitconfig-work

[includeIf "gitdir:~/git/"]
    path = ~/.gitconfig-git

Example ~/.gitconfig-work:

[user]
    email = [email protected]
    name = Waylon Walker

Key Settings #

Editor #

Opens nvim in insert mode for commit messages:

editor = nvim -c startinsert

Pager #

Uses bat for better output:

pager = bat --style=plain
diff = bat --plain

Autocorrect #

Automatically fix typos after 1 second:

[help]
    autocorrect = 10

Aliases #

squash-all #

Squash entire branch history into single commit:

git squash-all "Initial commit"

Implementation:

squash-all = "!f(){ git reset $(git commit-tree HEAD^{tree} -m \"${1:-A new start}\");};f"

restage #

Restage already-staged files:

restage = !git diff --name-only --cached | xargs git add

Credentials #

Uses GitHub CLI for authentication:

[credential "https://github.com"]
    helper =
    helper = !gh auth git-credential

[credential]
    helper = store

Delta Integration #

Delta provides syntax highlighting for diffs:

[pager]
    diff = delta
    log = delta
    reflog = delta
    show = delta

[delta]
    features = side-by-side line-numbers decorations
    syntax-theme = Dracula

Default Behaviors #

[init]
    defaultBranch = main

[push]
    default = current

[pull]
    rebase = true

[rebase]
    autoStash = true

[commit]
    gpgsign = false

Global Gitignore #

A ~/.global-gitignore file excludes files across all repos:

# IDE
.idea/
.vscode/
*.swp
*~

# OS
.DS_Store
Thumbs.db

# Temporary
*.log
*.tmp
.env.local

Workflows #

Starting a New Project #

# Personal project
cd ~/git/new-project
git init
git add .
git commit -m "Initial commit"

# Work project (uses work email automatically)
cd ~/work/company-project
git init
git add .
git commit -m "Initial commit"

Cleaning Up History #

# Squash everything to one commit
git squash-all "Clean history"

# Push with force
git push --force-with-lease

See Also #