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
| Alias | Full Command | Use Case |
|---|---|---|
git s | git status -sb | Short status with branch info |
git lg | git log --oneline --graph -20 | Visual log, last 20 commits |
git cm "msg" | git commit -m "msg" | Quick commit |
git ca | git commit --amend --no-edit | Amend last commit (same message) |
git wip | Stage all + commit “wip” | Save work in progress |
git undo | git reset --soft HEAD~1 | Undo last commit, keep changes |
git pf | git push --force-with-lease | Safe 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 moregit push -u origin branch-name. Justgit 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:
| Type | When to Use |
|---|---|
feat | New feature |
fix | Bug fix |
refactor | Code change that doesn’t fix or add |
docs | Documentation only |
test | Adding or updating tests |
chore | Build, tooling, dependencies |
perf | Performance improvement |
ci | CI/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)