Like most software developers, I spend a lot of my time in the terminal writing Git commands such as status
, commit
and push
(you know the drill), but when you actually add up all those keystrokes and realise how many seconds/minutes/hours you spend on writing them, that is exactly what it becomes - a lot of time.
It was pretty early on in my career that I started looking for ways to reduce the time I spent writing Git commands as it was a simple, repetitive task that was ripe for automation. I was then told about aliases and set about creating my own.
Note: My terminal setup is currently iTerm2 + zsh + Oh My Zsh. Here's a helpful guide to install this setup on your machine.
All of my aliases live in the ./zshrc
file at root
and they follow this syntax:
alias myalias='echo hello new alias'
Here is the complete list of all 10 Git aliases that I use on a daily basis:
alias gs='git status'
alias gc='git commit -m'
alias ga='git add'
alias gr='git reset HEAD'
alias m='git checkout master'
alias gd='git diff'
alias greb='git pull --rebase'
alias gp='git push'
alias gch='git checkout'
alias gm='git merge'
These aliases save me a ton of time and allow me to focus more on copying/pasting writing code. Shaving off a few seconds from every command really adds up and has definitely boosted my productivity as a whole.
PS. you can use aliases for any commands in the terminal. For example, another one of my favourites is alias cl='clear'
.
Aliases are super useful and if you can get into the habit of using them, you will soon feel the benefits!
Top comments (2)
Nice article.
Oh-my-zsh has a couple of plugins including git and docker.
This plugin enables multiple aliases including -
gco for git checkout
gcl for git clone
gst for git status
Please have a look, if this helps - github.com/ohmyzsh/ohmyzsh/blob/ma...
That's good to know! Some scary long commands in there too (I'm looking at
gbda
) 😅Thanks, Damanpreet 👍