While Git supports aliases and I am a big fan of Git aliases, (e.g. git lg
), the most valuable to me (and most used) aliases are shell aliases (e.g. gc
for git commit
).
While Git aliases allow you to define commands that start with git
(e.g. git lg
), a shell alias can be as short as you’d like (gc
). While this only saves a couple of keystrokes, when you use Git a lot this can be a huge savings.
Git Shell Aliases
There are lots Git Shell Aliases that can be set, for example if you’re using OhMyZsh you probably already have a list of OhMyZsh Git aliases available to you.
My Git Shell Aliases
I want my own personally curated list of Git shell aliases, so I define them individually in ~/.zshrc
since I’m using zsh. This is my list.
alias ga="git add"
alias gb="git branch"
alias gbsc="git branch --show-current"
alias gc="git commit"
alias gca="git commit --amend"
alias gcnv="git commit --no-verify"
alias gcanv="git commit --amend --no-verify"
alias gd="git diff"
alias gds="git diff --staged"
alias gdno="git diff --name-only"
alias gl="git lg"
alias go="git checkout"
alias gs="git status"
alias gsno="git show --name-only"
My full zsh configuration is online at github.com/salcode/salcode-zsh.
One I have been using a lot is a command I made that helps with agile development workflows where you’re usually working on very small tasks across many branches.
gnew
It detects the base branch name, checks it out, pulls, then creates a new branch with the given name.