When working with Git CLI we usually type lots of verbose and boilerplate commands. However, Git has alias support that might be handy and save a lot of “typing” energy as well as increase your productivity.
What is Git Alias
Basically Git Alias gives the ability to save some command with different name/nickname.
How to add Git Alias
There are 2 ways of adding new Git Alias:
- Adding to the git config file:
$ git config --global --edit
co = commit
2. Using Git CLI:
git config --global alias.co checkout
Note: This is just automated version of “Option 1” for adding single git alias.
How to use Git Alias
- So using the above example, instead of typing
git checkout, it’s now possible to use just
- Any additional parameters basically passed to the underlying command. Example, if you want to create and switch to a branch, instead of
git checkout -b my-branch, you can use
git co -b my-branch
Besides using Git CLI and aliases I would also suggest learning/mastering other Git tooling tips and tricks too in order to maximise your productivity and minimise repetitive work. Like IDE’s builtin Git support, or separate Git UIs like Github for Desktop, Sourcetree etc.