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.

  • Shell scripts with Git Bash 64-bit on Windows
  • pipe is returning empty string in bash in git for windows
  • Progress bar for svn checkout in text mode
  • Why does ssh-agent need root access?
  • How to export a function, from tmux.conf
  • What's the most proper way to remove an already deleted branch from tab-completion history?
  • What should I do? What I have missed?


  • GIT Pull deleted my commit
  • How to find latest non-merge commit message in Git?
  • heroku using git branch is confusing!
  • Merge 2 Different git Repos
  • Using Maven, Git: How do I tag the latest version of my code?
  • Git “commits left behind” when switching back to a branch from detached head
  • 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.