Skip to main content
Back to Tools
CLI

Git Aliases & Configuration

A collection of battle-tested Git aliases, configurations, and workflow shortcuts. Includes commit conventions, branch management, and interactive rebase patterns.

git aliases dotfiles workflow terminal

Published March 21, 2026

Overview

Every keystroke saved adds up. These Git aliases and configurations come from years of daily use across dozens of projects. The aliases below save roughly 200+ keystrokes per day for an active developer.

Add these to your ~/.gitconfig or set them via git config --global.

Essential Aliases

[alias]
  # Status & logs
  s = status -sb
  lg = log --oneline --graph --decorate -20
  ll = log --oneline --graph --all --decorate

  # Commit workflow
  cm = commit -m
  ca = commit --amend --no-edit
  wip = !git add -A && git commit -m 'wip: work in progress'

  # Branch management
  co = checkout
  cb = checkout -b
  br = branch -vv
  bd = branch -d
  bdd = branch -D

  # Stash
  sl = stash list
  sp = stash pop
  ss = stash push -m

  # Diff
  d = diff
  ds = diff --staged
  dw = diff --word-diff

  # Reset
  unstage = reset HEAD --
  undo = reset --soft HEAD~1

  # Sync
  pl = pull --rebase
  pf = push --force-with-lease
  sync = !git pull --rebase && git push

Quick Reference

AliasFull CommandUse Case
git sgit status -sbShort status with branch info
git lggit log --oneline --graph -20Visual log, last 20 commits
git cm "msg"git commit -m "msg"Quick commit
git cagit commit --amend --no-editAmend last commit (same message)
git wipStage all + commit “wip”Save work in progress
git undogit reset --soft HEAD~1Undo last commit, keep changes
git pfgit push --force-with-leaseSafe force push

Global Configuration

[core]
  editor = code --wait
  autocrlf = input
  pager = delta

[init]
  defaultBranch = main

[pull]
  rebase = true

[push]
  autoSetupRemote = true

[merge]
  conflictstyle = zdiff3

[diff]
  algorithm = histogram
  colorMoved = default

[rerere]
  enabled = true

Why These Settings

  • pull.rebase = true — Keep a linear history. Merge commits from pulls create noise.
  • push.autoSetupRemote = true — No more git push -u origin branch-name. Just git push.
  • merge.conflictstyle = zdiff3 — Shows the common ancestor in conflict markers. Makes resolving conflicts much easier.
  • diff.algorithm = histogram — Better diff output than the default Myers algorithm.
  • rerere.enabled = true — Remember how you resolved conflicts. Git applies the same resolution automatically next time.

Commit Message Convention

Follow conventional commits for clear, parseable history:

<type>: <description>

<optional body>

Types:

TypeWhen to Use
featNew feature
fixBug fix
refactorCode change that doesn’t fix or add
docsDocumentation only
testAdding or updating tests
choreBuild, tooling, dependencies
perfPerformance improvement
ciCI/CD changes

Examples:

git cm "feat: add category filter to tool hub"
git cm "fix: prevent search flicker on rapid typing"
git cm "refactor: extract date formatting utility"

Delta (Better Diffs)

Delta transforms your Git diffs with syntax highlighting and side-by-side views.

# Install
brew install git-delta

# Or on Linux
sudo apt install git-delta

Add to your ~/.gitconfig:

[core]
  pager = delta

[interactive]
  diffFilter = delta --color-only

[delta]
  navigate = true
  side-by-side = true
  line-numbers = true
  syntax-theme = Dracula

[merge]
  conflictstyle = zdiff3

Workflow Shortcuts

Add these shell functions to your .zshrc or .bashrc:

Create branch from latest main

gbc() {
  git checkout main && git pull --rebase && git checkout -b "$1"
}
# Usage: gbc feat/new-feature

Push and create PR

gpr() {
  git push -u origin "$(git branch --show-current)"
  gh pr create --fill
}
# Usage: gpr (pushes current branch and opens PR)

Clean merged branches

gclean() {
  git checkout main
  git pull --rebase
  git branch --merged | grep -v '\*\|main\|master' | xargs -n 1 git branch -d
}
# Usage: gclean (removes all merged local branches)

Interactive rebase last N commits

gri() {
  git rebase -i "HEAD~${1:-5}"
}
# Usage: gri 3 (interactive rebase last 3 commits)