In this article, I’m going to cover handy shortcuts that can make your life in using git in the terminal faster and more convenient.
I really love using Windows Terminal, it allows you to use any type of shell that you want, customize it, and extend it to the limit of your own imagination. I cannot recommend enough the great article from Scott Hanselman that teaches you how to unlock most of the potential within Windows Terminal, really making it your own.
Once you get used to working with the terminal is pretty hard to go back, the speed at which you are used to writing the commands and your own shortcuts make it a flow-like experience to daily work.
A few of the things that can help you with your daily work are git shortcuts
#git shortcuts Git shortcuts are just another name for the git configuration file, this being a global git config setup that essentially dictates how git should behave on your dev box.
the only thing you need to get started is to open your terminal and type in a command like this one
git config --global alias.co checkout
this will append a configuration setting in your .git config file and will allow you to replace the ol'
git checkout BRANCH_NAME
for a simpler
git co BRANCH_NAME
that might seem small, but you are saving 6 characters multiple times a day. Measure that in a year, or even your professional life.
likewise, other commands can be simplified. Here is a list of the ones I use:
- to create a branch
git config --global alias.br branch
- to commit
git config --global alias.ci commit
- to review your current status
git config --global alias.st status
- to check the last commit
git config --global alias.last 'log -1 HEAD'
to cherry-pick a commit
git config --global alias.cp cherry-pick
if you also unlock the power of WSL you can extend git (and Windows for that matter) with the help of Linux commands and applications in one seamless shortcut:
- to prune and delete old local branches
git config --global alias.purge '!git fetch -p && git branch -vv | awk "/: gone]/{print \$1}" | xargs git branch -d'
with the help of this shortcut
git prune
you automatically fetch and prune remote branches, list them, send it to Linux’s awk to filter out only the pruned ones, and then feed those to the delete command.
just make sure that you have git, wsl, and a distro with awk installed in your box to make use of this shortcut.
for today that’s it. thanks for reading.