My Git bash forgets my aliases. What can I do?
I am working with the latest Git bash for Windows, on my laptop running Windows 7.
When I define my aliases like:
$ alias gitc='git commit -a'
Everything works well during the session, but I cannot recover them if I close and open the bash.
The command history is preserved, though.
What should I do? What I have missed?
6 Solutions collect form web for “My Git bash forgets my aliases. What can I do?”
When you open the git bash type in the command
Following this type
You can then add your aliases to this file. Save the file and reopen the git bash and your aliases should work as expected.
This method allows you to create aliases for any bash command available in git bash however as others have answered it is also possible to create git specific aliases using git itself.
Instead of modifying your bash_profile you can setup a .gitconfig and add aliases like this:
[alias] st = status ci = commit br = branch co = checkout df = diff lg = log -p
Create the .bashrc file in the home directory:
touch ~/.bashrc vim ~/.bashrc
In the file
~/.bashrc add the aliases:
alias gitc='git commit -a' # -- ... and your other aliases here ...
Save the file (press
<ESC>:wq in vim). Reload the file such that bash is aware of the changes made:
These steps work for me in Win 7/Win 8 with Git bash (MINGW32)
For Windows Users :
Be sure you’re in the home directory ,
the Simplest way is creating a
.bash_profile File and insert your aliases within
note : to edit it with Notepad execute this line first :
git config core.editor notepad
then create the file and add your alias as following :
now you can add your aliases to the
.bash_profile like :
alias yourAlias=’your Command Here’
alias AnotherAlias=’your Command Here’
save the file by pressing ctrl +s or
You need to put them in your .bash_profile. Then they’ll get reset every time a new login shell starts up.
I know you’ve already gotten an answer, but you might want to consider using git’s own alias system, which is explained in the git config help page. Then they can be per-repo as well as system-wide or per-user.