How to alias command in Git Bash for Windows downloaded from git-scm.com ?
I mean Bash commands not Git.
(windows7)
Edit:
Writing aliases i
Go to: C:\Users\ [youruserdirectory] \bash_profile
In your bash_profile file type - alias desk='cd " [DIRECTORY LOCATION] "'
Refresh your User directory where the bash_profile file exists then reopen your CMD or Git Bash window
Type in desk to see if you get to the Desktop location or the location you want in the "DIRECTORY LOCATION" area above
Note: [ desk ] can be what ever name that you choose and should get you to the location you want to get to when typed in the CMD window.
$ alias gpuom='git push origin master'
$ alias
hit Enter.$ vim ~/.bashrc
and hit Enter (I'm guessing you are familiar with vim).#My custom aliases
alias gpuom='git push origin master'
alias gplom='git pull origin master'
$ alias
hit Enter.To configure bash aliases, it's the same as if you were on a Unix platform: put them in a .bashrc
in your home:
cd
echo alias ll=\'ls -l\' >> .bashrc
To have this change taken into account you should then either source this file (ie: run source .bashrc
) or restart your terminal
(In some cases* you can find equivalent for .bashrc
file in C:\Users\<username>\AppData\Local\GitHub\PortableGit_\etc\profile.d\aliases.sh.
And you should add aliases in aliases.sh.
)
(*this case is when you install Git for Windows GUI release from https://git-scm.com/download/win that contains GitBash)
Follow below steps:
Open the file .bashrc
which is found in location C:\Users\USERNAME\.bashrc
If file .bashrc
not exist then create it using below steps:
C:\Users\USERNAME\
.notepad ~/.bashrc
.bashrc
file.Add below sample commands of WP CLI, Git, Grunt & PHPCS etc.
# ----------------------
# Git Command Aliases
# ----------------------
alias ga='git add'
alias gaa='git add .'
alias gaaa='git add --all'
# ----------------------
# WP CLI
# ----------------------
alias wpthl='wp theme list'
alias wppll='wp plugin list'
Now you can use the commands:
ga
instead of git add .
wpthl
instead of wp theme list
Eg. I have used wpthl
for the WP CLI command wp theme list
.
Yum@M MINGW64 /c/xampp/htdocs/dev.test
$ wpthl
+------------------------+----------+-----------+----------+
| name | status | update | version |
+------------------------+----------+-----------+----------+
| twentyeleven | inactive | none | 2.8 |
| twentyfifteen | inactive | none | 2.0 |
| twentyfourteen | inactive | none | 2.2 |
| twentyseventeen | inactive | available | 1.6 |
| twentysixteen | inactive | none | 1.5 |
| twentyten | inactive | none | 2.5 |
| twentythirteen | inactive | none | 2.4 |
| twentytwelve | inactive | none | 2.5 |
For more details read the article Keyboard shortcut/aliases for the WP CLI, Git, Grunt & PHPCS commands for windows
Using Windows and MINGW64 GitBash ((mintty 3.2.0), i found the file under:
C:\Users\<user name>\AppData\Local\Programs\Git\etc\profile.d\aliases.sh
Just add the alias there and i worked for me
I had the same problem, I can't figured out how to find the aliases used by Git Bash on Windows.
After searching for a while, I found the aliases.sh file under C:\Program Files\Git\etc\profile.d\aliases.sh
.
This is the path under windows 7, maybe can be different in other installation.
Just open it with your preferred editor in admin mode. After save it, reload your command prompt.
I hope this can help!