Git's command-line interface is immensely powerful, but typing verbose flags repeatedly reduces daily productivity. Adding these battle-tested aliases to your ~/.gitconfig streamlines your workflow.
The Aliases
Run the following terminal commands or paste them directly into your ~/.gitconfig file under the [alias] section:
[alias]
# Clean visual commit graph tree
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
# Quick short status
s = status -s
# Unstage files without changing contents
unstage = restore --staged
# Undo the last commit while keeping staged file changes
undo = reset --soft HEAD~1
# Discard all uncommitted changes and clean untracked files
wipe = !git reset --hard HEAD && git clean -fd
# View recently modified branches sorted by last commit date
recent = branch --sort=-committerdate --format="%(committerdate:relative)%09%(refname:short)"
# Pull changes including submodules with fast-forward only
up = pull --ff-only --prune --recurse-submodulesHow to Apply
To add an alias using the CLI directly:
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
git config --global alias.s "status -s"
git config --global alias.undo "reset --soft HEAD~1"Quick Verification
# View the tree graph:
git lg
# Inspect staged changes compactly:
git s