Aliases

Useful Aliases for Everyday Commands

An alias is a configuration key, alias.<name>, whose value Git 1,932 expands in place of the name. Values starting with ! run as a shell command instead, from the top of the working tree, so they can use pipes and other programs:

Four global aliases and what they printShell
git config set --global alias.st "status --short --branch"
git config set --global alias.lg "log --graph --date=short --format='%h %ad %s%d'"
git config set --global alias.unstage "restore --staged"
git config set --global alias.recent '!git branch --sort=-committerdate | head -n 3'
git st
git lg -3
git recent
Output
## main...origin/main
* b88115b 2026-09-25 chore(release): 1.2.0 (HEAD -> main, tag: v1.2.0, origin/main,
  origin/HEAD)
* 4d1f243 2026-09-25 build: name the repository for changelog links
* c1085fd 2026-09-25 docs: describe the branching workflow
* main
  experiment/covers
  release/1.1

Arguments follow the expansion, so git lg -3 became git log --graph ... -3, and git help <alias> shows what an alias expands to. Other aliases worth having are amend = commit --amend --no-edit and undo = reset --soft HEAD~1. An alias cannot replace a built-in command (alias.log is ignored), and a shell alias runs whatever it says, so read a stranger's aliases before copying them.