You could also call them Git shortcuts, and it would be the same. Do not get bogged down with the terms. The point of this article is to show you that you can create shorter commands for your usual Git commands.
How did I discover this? I became bored with repeating
git commit -m "message here" one hundred times a day. As a result, I started looking for ways of speeding this process, and I came across Git aliases.
To set up a new alias for a command, we need to use the
git config command.
git config --global alias.c checkout git config --global alias.st status git config --global alias.cm 'checkout master' git config --global alias.b branch git config --global alias.c checkout git config --global alias.ci 'commit -m' git config --global alias.p pull git config --global alias.cb 'checkout -b' git config --global alias.sc 'switch -c'
The aliases above are the ones I am using. You are free to add as many as you want, and however you want.
To add new ones, use the following command
git config --global alias.[insertYourShortcut] [gitCommand].
Let’s say we want to checkout master. To do so, we run
git cm based on the aliases created above. That’s all.
To easily display your git aliases run this command in your terminal –
! git config --get-regexp ^alias\. | sed -e s/^alias\.// -e s/\ /\ =\ /.
Now you can use
git alias to list all the aliases you have created.
Tada! That’s all!