log / git aliases
If you’re a frequent user of Git in your terminal, you might already be familiar with the power of ZSH. Personally, I rely on ZSH to streamline my Git commands, and one of my go-to tools for this is the ZSH plugin. However, there’s another trick up my sleeve to supercharge Git commands even further – setting up custom aliases using Git configuration.
Setting up Git aliases using git config can significantly enhance your workflow. It not only saves keystrokes but also makes your Git commands more intuitive. If you’re new to this concept, you can find detailed information in the Git documentation.
Let me share some of my favorite Git alias configurations:
# basic command
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.br branch
# log command
git config --global alias.lg "log --graph --oneline --all --decorate"
# show last commit
git config --global alias.last "log -1 HEAD"
# ammend last commit
git config --global alias.amend "commit --amend"
# undo last commit
git config --global alias.undo "reset HEAD~1 --mixed"
# diff command
git config --global alias.df diff
git config --global alias.dc diff --cached
# list branch (compact)
git config --global alias.b "for-each-ref --format='%(refname:short)' refs/heads/"
# list remote branch
git config --global alias.lrb "branch -r"