How many times a day do you write
git commit -m and
git push in your terminal? Tons! Wouldn't it be nice if there was a faster way to write out the commands you use every day? Well, there is and it's aliases.
I'll be going over using aliases with Zsh which is now the default shell for Macs using Catalina. Zsh is an extended version of Bash but it has a few additional features and has support for plugins and themes.
You'll need to open your Zsh configuration file (
.zshrc) and add the following syntax at the bottom of the file to make your alias:
I use Ember at work so I'm constantly writing out the full command to run my tests. Instead of having to write
ember test --server --launch=false every time I've set up the following alias:
alias ets="ember test --server --launch=false"
Now, whenever I want to run my tests I use the command
ets and have saved myself a little bit of time typing!
Another advantage of using Zsh as your shell is that you can install Oh My Zsh which is a framework for managing your Zsh configuration.
You can install Oh My Zsh via curl:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Besides having awesome plugins and themes, Oh My Zsh also includes a ton of git aliases. You can see which ones are available by running
alias. There are a ton of preconfigured aliases and all you have to do is add them to your
.zshrc configuration file.
What's your favorite Git alias? I'd love to know in the comments below!