How to create a custom Git command
Today, we’ll show you how to create a custom Git command or set aliases in Git. In this article, we will show you two different ways to set shortcut Git command.
Create a custom Git command
1. Using Git Bash
Open bash terminal and type git command. For instance:
1 2 | $ git config --global alias.aa 'add .' $ git config --global alias.s status |
It will eventually add those aliases on .gitconfig file.
2. Using .gitconfig file
Open .gitconfig
file located at C:\Users\<USERNAME>\.gitconfig
in Windows environment. Then add following lines:
1 2 3 4 5 | [alias] aa = add . s = status ... ... |
Use the following custom command to execute the git command.
1 2 3 4 5 | # To execute $ git add . git aa # To execute $ git status git s |
That’s it for today.
Thank you for reading. Happy Coding..!! 🙂