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.

  • Running MinGW/MSYS tools inside msysgit
  • How to make git-svn use specific version of SVN?
  • Authentication failed on tfs server
  • Bash environment variable not updating
  • How to stop git hanging on commit in cygwin bash
  • Check if git remote exists before first push
  • What should I do? What I have missed?


  • Version control a content management system?
  • Merge changes of copied repository without true common ancestor in git
  • How to organize files in Git Repository
  • Git rebase a pushed feature branch
  • How to make a Git merge operation ignore identical changes made to both branches?
  • Sign Git tag with Maven release plugin?
  • 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 touch .bash_profile.
    Following this type vim .bash_profile.
    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:

      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:

    source ~/.bashrc

    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 :

    notepad .bash_profile

    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 File>save Menu

    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.

    Git Baby is a git and github fan, let's start git clone.