How to alias command in Git Bash for Windows downloaded from git-scm.com ?
I mean Bash commands not Git.
(windows7)
Edit:
Writing aliases in .bashrc
file (as suggested by @gturri) not adding it in console.(after system reboot)(I have never wrote alias for ls
command so it should be some default alias.)
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!
$ 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.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.
There is two easy way to set the alias.
Using Bash
Open bash terminal and type git command. For instance:
$ git config --global alias.a add
$ git config --global alias.aa 'add .'
$ git config --global alias.cm 'commit -m'
$ git config --global alias.s status
---
---
It will eventually add those aliases on .gitconfig file.
Updating .gitconfig file
Open .gitconfig file located at 'C:\Users\username\.gitconfig' in Windows environment. Then add following lines:
[alias]
a = add
aa = add .
cm = commit -m
gau = add --update
au = add --update
b = branch
---
---
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
Source: Stackoverflow.com