Msysgit bash is horrendously slow in Windows 7

GitWindows 7Msysgit

Git Problem Overview


I love git and use it on OS X pretty much constantly at home. At work, we use svn on Windows, but want to migrate to git as soon as the tools have fully matured (not just TortoiseGit, but also something akin the really nice Visual Studio integration provided by VisualSVN). But I digress...

I recently installed msysgit on my Windows 7 machine, and when using the included version of bash, it is horrendously slow. And not just the git operations; clear takes about five seconds. AAAAH!

Has anyone experienced a similar issue?


Edit: It appears that msysgit is not playing nicely with UAC and might just be a tiny design oversight resulting from developing on XP or running Vista or 7 with UAC disabled; starting Git Bash using Run as administrator results in the lightning speed I see with OS X (or on 7 after starting Git Bash w/o a network connection - see @Gauthier answer).

Edit 2: AH HA! See my answer.

Git Solutions


Solution 1 - Git

You can significantly speed up Git on Windows by running three commands to set some config options:

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

Notes:

  • core.preloadindex does filesystem operations in parallel to hide latency (update: enabled by default in git 2.1)

  • core.fscache fixes UAC issues so you don't need to run Git as administrator (update: enabled by default in Git for Windows 2.8)

  • gc.auto minimizes the number of files in .git/

Solution 2 - Git

The solution for slowness on Vista or 7 appears to be running Git Bash using Run as administrator (or disabling UAC for the Git Bash shortcut...or disabling UAC entirely). The difference is night and day and using git on 7 is awesome again.

This appears to be related to a known issue and, as I speculated, XP as a development environment for msysgit is partially responsible.

Solution 3 - Git

For me the issue was the use __git_ps1 in the shell prompt - I guess due to slow disk access in msysgit.

Solution was to remove $(__git_ps1) from the PS1=... lines in /etc/profile

quick test if this solution applies: in a git shell, type export PS1='$ ' and check the speed of your operations.

Solution 4 - Git

Tried just about all tips here (including the one from my other answer) on a new machine, but they didn't work, Git still slow as hell.

Then I had a look at the virusscanning software (that was pre-installed) : I disabled McAfee Security Center's realtime scanning, and presto: git is blazing fast now! Time needed for "git svn rebase" dropped from 30s to 5s (!).

I hope this is helpful to other people still having issues with slow Git on Windows, I lost hours figuring this out.

Solution 5 - Git

Alas 'Run as Administrator' didn't work for me - but as Kevin L found, disconnecting the network adapter, launching git bash, then reconnecting worked fine. So I wrapped this up in a batch script and put a shortcut to it in my Start menu, flagged to run as admin:

netsh interface set interface "Local Area Connection" DISABLED
cd "%USERPROFILE%\Documents\Visual Studio 2010\Projects"
start cmd /c ""C:\Program Files\Git\bin\sh.exe" --login -i"
netsh interface set interface "Local Area Connection" ENABLED

Works a treat as long as I remember my network gets momentarily cut off.

(Win 7 Professional SP1, Git version 1.7.8-preview20111206)

Solution 6 - Git

A colleague of mine had this behaviour whenever Outlook was running. Trying killing outlook and test again.

You could also try to test:

  • without connection to any network,
  • without antivirus running,
  • without any other program running.

Solution 7 - Git

We found that, when running on certain user accounts, separate git.exe instances blocked on a call to WaitForSingleObject(), so only a single git.exe operation could effectively run at once. Changing the user account worked around this issue.

Details here: https://stackoverflow.com/a/13054022

Solution 8 - Git

I have MacAffee and telling it to exclude the .git directory and all subdirectories from real-time-scanning addressed the performance problem.

Solution 9 - Git

As found in this issue, running with UAC virtualization turned off (it's not needed to disable UAC entirely) makes a big difference.

This post explains how to turn it off (see the bottom of the post, just one registry setting).

On one (large) SVN repo I'm connecting to, making just the above change dropped the time needed for "git svn rebase" from 15s to 5s, a factor 3 improvement.

Solution 10 - Git

If turning off UAC doesn't improve performance, try turning off the luafv driver. This worked for me after trying almost everything on this page and the couple of similar questions. Git has gone from unusably slow to pretty decent.

Open 'regedit' and find the registry key

HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/services/luafv

Change the value of Start from 2 to 4.

I found the details on how to disable luafv here. Note that I personally have no idea what luafv is or does. That page gives various warnings about bad things that might happen if you turn it off, which you should probably take seriously.

EDIT: The comment below pointed out I got this the wrong way round (the link has it the right way round). It is fixed now. Sorry to the people whose registries I trashed :)

Solution 11 - Git

An alternative to messing with the Windows 7 UAC may be to install mysysgit outside of your Program Files folder. For example instead of "C:\Program Files (x86)\Git", try installing in "C:\git"

I tried fiddling with 'Run as admin' and UAC controls to no avail, but gave up and started over a fresh install. I was getting about 15KiB/s max before, but is now over 60kiB/s.

Solution 12 - Git

I've just been troubleshooting this for a while and had a hard time pinpointing the source of the problem. In the end I found two things that had a dramatic impact:

  • Turning off the Windows Search service. This had a dramatic effect on performance.
  • Closing Git Extensions. Having the Git Extensions Browse window open in the background caused Cygwin git command execution times to increase by a seemingly random factor of up to around 10.

Solution 13 - Git

The issue here might be the bash-completion if that's enabled, which is quite a bit slower on Windows than Linux.

Try setting the PS1-variable to something simple like "$ ", and see if this speeds things up. If it does, be aware that there's been some optimizations to the bash-completion in recent-ish git-versions. Perhaps you need to upgrade.

Solution 14 - Git

This worked for me. Don't expect it will be a one size fits all solution.

Check the $HOME environment variable in bash and windows. If it points to a user account, check the user's windows profile/permissions. Change either the user account or the $HOME accordingly.

Solution 15 - Git

I've encountered the same problem running git for Windows (msysgit) on Windows 7 x64 as a limited user account for quite some time. From what I've read here and other places, the common theme seems to be the lack of administrative privileges and/or UAC. Since UAC is off on my system, the explanation that it is trying to write/delete something in the program files directory makes the most sense to me.

In any case, I've resolved my problem by installing the portable version of git 1.8 with zipinstaller. Note that I had to unpack the .7z distribution file and repack it as a zip in order for zipinstaller to work. I also had to manually add that directory to my system path.

The performance is fine now. Even though it is installed in the Program Files (x86) directory, which I don't have permissions for as a limited user, it doesn't seem to suffer from the same problem. I ascribe this either to the fact that the portable version is a bit more conservative in where it writes/deletes files, which is probably the case, or to the upgrade from 1.7 to 1.8. I'm not going to try to pin down which one is the reason, suffice to say it works much better now.

Solution 16 - Git

You might want to try uninstalling msysgit, restart windows, install latest version of msysgit. It seemed to do the trick for me. I found this suggestion here:

https://stackoverflow.com/a/4506192/1413941

EDIT

PS I already had UAC disabled before I ran into slow Git issues, so I don't know if disabling UAC is required or not to get Git going fast.

Solution 17 - Git

The best solution is to run as administrator, as pointed out. However another option to make git status fast, at least, is trustctime = false. Before that git status took about 30 seconds and after that it is the same amount that is shown in the output - It took X seconds to...

Solution 18 - Git

You might also gain an important performance boost by changing the following git configuration :

git config --global status.submoduleSummary false

When running the simple git status command on Window 7 x64, it took my computer more than 30 seconds to run. After this option was defined, command is immediate.

Activating Git's own tracing as explained in the following page helped me found the origin of the problem, which might differ in your installation : https://github.com/msysgit/msysgit/wiki/Diagnosing-why-Git-is-so-slow

Solution 19 - Git

It's probably a matter of the prompt which analyzes your Git repository. You can test by doing "clear" somewhere outside of a Git repository. And you can accelerate it by either patching git-completion.bash or by playing tricks with core.filemode.

As for the Visual Studio integration: This is Open Source. It is unfair to expect others to work for you for free.

I also find it rather funny not to ask the question on the msysGit mailing list, but now I digress.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKevin L.View Question on Stackoverflow
Solution 1 - GitshoelzerView Answer on Stackoverflow
Solution 2 - GitKevin L.View Answer on Stackoverflow
Solution 3 - GitchrisxxyyView Answer on Stackoverflow
Solution 4 - GitTom De LeuView Answer on Stackoverflow
Solution 5 - GitDaniel HumeView Answer on Stackoverflow
Solution 6 - GitGauthierView Answer on Stackoverflow
Solution 7 - GitMatthew SkeltonView Answer on Stackoverflow
Solution 8 - GitAlex BrownView Answer on Stackoverflow
Solution 9 - GitTom De LeuView Answer on Stackoverflow
Solution 10 - GitjwgView Answer on Stackoverflow
Solution 11 - GitFrank YinView Answer on Stackoverflow
Solution 12 - GitbjosView Answer on Stackoverflow
Solution 13 - GitkusmaView Answer on Stackoverflow
Solution 14 - GitDeepakView Answer on Stackoverflow
Solution 15 - GitBinary PhileView Answer on Stackoverflow
Solution 16 - GitHerr GrumpsView Answer on Stackoverflow
Solution 17 - GitTS'View Answer on Stackoverflow
Solution 18 - GitOlivierView Answer on Stackoverflow
Solution 19 - GitDschoView Answer on Stackoverflow