Creating aliases to execute Git commands more effectively.
Last week, I discussed with a friend how we can use the Git Bash console to create simple aliases that make executing Git commands more convenient and efficient. I use Visual Studio Code on my Windows machine, and the default terminal in it is Git Bash.
To start, I opened my user directory by pressing Win+R
and typing %USERPROFILE%
.
Next, I created a .bashrc
file and added the following lines:
After saving the file, I closed the Git Bash terminal in VSCode and reopened it. Now, when I run the alias
command, I can see all the aliases listed. If I ever forget an alias, I can simply execute alias
to view them.
Finally, I can now execute an alias command like gaa
in Git Bash, which results in running the command I wrote in my .bashrc file, git add --all
, making it easy to stage all changes across the repository.