Git Aliases

Image of Author
March 15, 2022 (last updated October 21, 2022)

Setting 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, copied from my ~/.gitconfig. Of particular note, in my opinion, are ap, cane, cm, l, and s.

[alias]
        ap = add -p
        br = branch
        bra = branch --all
        co = checkout
        c = commit
        ca = commit --amend
        cane = commit --amend --no-edit
        cm = commit --message
        l = log
        lol = log --oneline
        lolg = log --oneline --graph
        l3 = log -3
        l5 = lol -5
        l9 = lol -9
        s = status --short
        st = status