Why aliases matter
Git aliases turn long, verbose commands into short, memorable shortcuts. Once you have a handful of aliases configured in your ~/.gitconfig, you stop fighting the CLI and start flowing through it. Most developers type the same five or six commands hundreds of times a day; aliases pay back the setup cost within hours.
Configuring aliases
Aliases live under the [alias] section of your Git config. You can add them with git config or by editing the file directly.
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
Ten aliases worth adopting
The following ten aliases form a battle-tested core. Drop them into the [alias] section of ~/.gitconfig:
[alias]
st = status -sb
co = checkout
br = branch
ci = commit
last = log -1 HEAD --stat
unstage = reset HEAD --
lg = log --oneline --graph --decorate --all
amend = commit --amend --no-edit
wip = !git add -A && git commit -m 'WIP'
undo = reset --soft HEAD~1
st gives you a compact status with branch info. lg draws the commit graph in one line per commit, decorated with branch and tag names. amend tacks staged changes onto the last commit without prompting for a new message. wip is invaluable when you need to switch branches mid-thought; undo reverses it once you come back.
Shell aliases versus Git aliases
You can also alias at the shell level. The shell-level approach lets you alias the git binary itself:
# In ~/.zshrc or ~/.bashrc
alias g='git'
alias gst='git status -sb'
alias gp='git pull --rebase'
Combining the two layers - g st in the shell expands to git status -sb - reduces every common operation to two or three keystrokes.
Aliases that run shell commands
Prefixing an alias with ! tells Git to execute it as a shell command. This unlocks composition:
[alias]
cleanup = "!git branch --merged main | grep -v '\\*\\|main\\|master' | xargs -n 1 git branch -d"
root = "!pwd"
publish = "!git push -u origin $(git symbolic-ref --short HEAD)"
cleanup deletes every local branch already merged into main. publish pushes the current branch and sets upstream tracking in one step - particularly useful when you create branches frequently.
Discovering and auditing your aliases
List every alias currently configured:
git config --get-regexp '^alias\\.'
Treat your alias list like any other dotfile - check it into a personal dotfiles repo, version-control it, and sync across machines. The five minutes you spend tuning aliases will save you hours every month.