How to create a Git alias for multiple commands and parameters
In this short article, we will show you how to create a Git alias for multiple commands and parameters. In the previous article, we explained you how to set a custom Git command.
Git Alias – Multiple Commands and Parameters
1. Set multiple commands
Use the following command to set alias for multiple commands.
1 2 | [alias] chs = !git branch && git status |
1 | git chs -> git branch && git status |
2. Pass parameters in Git alias
To set parameters in Git alias, use the following command.
1 2 | [alias] chs = !git checkout $1 && git status && : |
If you add && :
to the end of your alias, then the spurious argument is consumed into a location tag.
1 | git chs demo -> git checkout demo && git status |
I hope you find this article helpful.
Thank you for reading. Happy Coding..!! 🙂