Process and Tooling

Speed up git bash on Windows

Recently, I've been struggling with performance in Git Bash on Windows. Just doing a 'git status' takes several seconds.

Directory browsing was also crazy slow, just TAB completing possible filenames was taking a few seconds.

After doing a bit of Googling, I found a few tips that made a huge difference to my experience.

Make the following changes to you git config:

git config --global core.preloadindex true
git config --global core.fscache true
git config --global 256

Another speedup came when I redefined my shell prompt. By default, the bash shows you which branch you're currently on, and for some reason the method it uses to get the branch is quite slow.

I found the following change on a StackOverflow post that seems to work way faster:

  1. Go to your git install directory (Mine is c:\Program Files (x86)\Git
  2. In the etc folder, open the file 'profile' in a text editor
    • This file is executed when the bash shell is initialized, you can do a lot of customization in here
  3. Near the bottom, you will find some commands related to setting a variable called PS1 (PS1 = ...)
  4. Either replace it or just append the following lines after it
fast_git_ps1 ()
printf -- "$(git branch 2>/dev/null | grep -e '* ' | sed 's/^..(.*)/ {\1} /')"
\033[32m]\u@\h [\033[33m\w$(fast_git_ps1)\033[0m]

Make sure the PS1 variable is not changed again later in the script.

These tips all came from a StackOverflow post:, there may be more there to help, but just the above changes made a massive change for me.