Adding alias in your Gitbash terminal can help you speed up your workflow when using the terminal. β‘οΈ
In this tutorial, I am going to guide you how you can configure the aliases for your day-to-day commands. π
First of all open the Gitbash
and type following command in it.
alias
And you will see an output something like below image. It will give the list of aliases which are configured. π
If you see nothing, then no aliases are set. So don't worry. π
To set the alias for any command type following in the terminal. β¨
alias new_command_name='old_command_name'
The alias set within the image will create an alias for git commit
. Now I can just type gc -m <msg>
and it will commit my code. π―
And that's it, you have configured your first alias. Hurray!!! π
Hold on, it's not over yet. β οΈ If you just close the terminal and try to re-run that alias again, it will throw error like this. π±
What?! You will think I just set it and now it's gone. Yup it's gone. π Because aliases set with alias
are session based means they are deleted once the terminal is closed off.
So how can we make it permanent??? π€
Well, there is a way make it permanent. π‘ It's .bash_profile
file, it's location differ from OS to OS. For windows it would be OS_Drive/Users/<your_user_name>
and for ubuntu it's present in root
and you can run ls -la
to see it. π
Open the .bash_profile
file and edit it. βοΈ
Just add the following line of snippet in that file. Do not remove anything from that file, just go to very end of it and insert new line and copy-paste. β οΈ
Congratulations. You have created your first permanent alias, I repeat first permanent alias of your. π
Now you can configure as much as aliases you want, and you just need to add them within .bash_profile
file. π§β¨
Top comments (0)