Helpful git aliases and config settings

If you use Oh My Zsh, there’s a gold mine of aliases at your fingertips.

Two personal aliases that I use all the time:
glm - See the commits for the current branch since it branched off from master.

alias glm='git log --oneline master..'

gccp - Copy the current (short) commit hash to the clipboard (pbcopy usually only on OSX, replace with xclip or whatever else you use if needed).

I use this when making changes on a Pull Request. It’s super helpful to respond to a comment and include the commit hash with makes the change being discussed. Github automatically turns this text (if the commit exists on GH) into a link to the commit, making it super easy for followup reviews, etc.

alias gccp="git rev-parse --short HEAD | tr -d '\n' | pbcopy"
3 Likes