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 "commit --message"
git config --global --unset

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.bra=branch --all
alias.c=commit --amend
alias.cane=commit --amend --no-edit --message --oneline
alias.lolg=log --oneline --graph
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.