Gatlin.io Icon
Image of Austin Gatlin's face
March 15, 2022

Git Aliases

Set global aliases

For example, to setup git cm to be git commit --message, and then to immediately remove it:

git config --global alias.cm "commit --message"
git config --global --unset alias.cm

List global config

Your global config will include your aliases.

git config --global -l # or --list

Aliasing git in the shell

In your shell settings file, e.g., ~/.zshrc you can setup a git alias

alias g='git'

This lets you run commands like g cm "My commit message."

Some of my aliases

As of this writing, here are some of my git aliases

alias.ap=add -p
alias.br=branch
alias.bra=branch --all
alias.co=checkout
alias.c=commit
alias.ca=commit --amend
alias.cane=commit --amend --no-edit
alias.cm=commit --message
alias.lol=log --oneline
alias.lolg=log --oneline --graph
alias.st=status
alias.s=status --short

For example, when my commit-hook formatter runs some changes, I can observe them with g ap, or just run g add . to add them all, and then g cane to amend the changeset to the previous commit.