step by step guide on how to set up a git bash alias with arguments globaly on Windows
- Windows OS
- git installed
- git bash
the goal of this example is to clone any repo from your GitHub profile, you can apply the same logic and steps to setup any alias
Going from this :
git clone https://github.com/zackAJ/<project-name>
To this :
clone <project-name>
in this example, I'm using my own GitHub profile URL: https://github.com/zackAJ/
don't forget to replace it with your own URL.
alias clone='fn(){ git clone https://github.com/zackAJ/$1; } ; fn $1'
where:
clone
is the name of the alias, you can name this to anything you like.$1
is going to be the argument that we pass to the function AKA ourrepo name
.
once your command is ready copy it and follow these steps Steps
1- go to C:\Program Files\Git\etc\profile.d
2- open aliases.sh
with a text editor of choice as an administrator
3- paste your alias to add it to the list of global aliases and save
4- to check if the alias was added open git bash and enter the alias
command
alias
5- test the alias by adding a repo name (my repo's name is alias)
clone alias
and that's it ! more copy-paste ready aliases are gonna be added soon.