Let’s explore how you can set up aliases on your terminal to save you some keystrokes.
We’ll also briefly mention Git. If you are new to git, check out my other post: Git Going with Git
Tired of typing git status every single time? Using aliases, you can make it such that typing
git st results in
git status being executed. This works for longer commands as well, for example, in my .gitconfig I have this command:
lg. And by calling this abbreviated command
git lg, we can get a nice color-coded
git log with minimal effort.
Okay! Time to try adding our own git aliases! Using this command from our home directory, we can view and edit or
The first time you open up your
.gitconfig, it may look something like this:
We can add the following convenience git aliases by adding the code below under your existing user information:
Another git alias I recommend is
git pull –rebase:
Note that you can also set
git pull --rebaseas a default behaviour with
git config --global pull.rebase true
pull by default use the
–rebase flag eliminates unnecessary merge commits which provides no helpful information and pollutes the git commit history.
Likewise, for terminal aliases, we can edit our
.bashrc from our home directory:
Now, instead of typing the original commands, you save yourself a few keystrokes and do it better with aliases! Especially for common commands such as
git status and
git commit, it’s a good idea to have abbreviations for them.
Note: On OS X, you should set up
.bash_profile to source
The aliases I have used in this post are by no means definitive must-have aliases, and there are plenty of other useful aliases outside of the above examples. For more on aliases, I recommend the two sources below.
📬 Get updates straight to your inbox!
Subscribe to my newsletter to make sure you don't miss anything.