How to create a custom Git command
📅December 30, 2022
🗁Git
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:
$ 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:
[alias]
aa = add .
s = status
...
...
Use the following custom command to execute the git command.
# To execute $ git add .
git aa
# To execute $ git status
git s
That’s it for today.
Thank you for reading. Happy Coding..!! 🙂