git Msysgit bash 在 Windows 7 中非常慢
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2835775/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Msysgit bash is horrendously slow in Windows 7
提问by Kevin L.
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...
我喜欢 git 并且在家里经常在 OS X 上使用它。在工作中,我们在 Windows 上使用 svn,但希望在工具完全成熟后立即迁移到 git(不仅仅是TortoiseGit,还有类似于VisualSVN提供的非常好的 Visual Studio 集成)。但我离题了...
I recently installed msysgiton my Windows 7 machine, and when using the included version of bash, it is horrendouslyslow. And not just the git operations; clear
takes about five seconds. AAAAH!
我最近安装msysgit我的Windows 7机器上,并使用bash所包含的版本时,它的窘况慢。不仅仅是 git 操作;clear
大约需要五秒钟。啊啊啊!
Has anyone experienced a similar issue?
有没有人遇到过类似的问题?
Edit: It appearsthat msysgit is not playing nicely with UACand 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).
编辑:似乎msysgit 不能很好地与UAC配合使用,这可能只是由于在 XP 上开发或在禁用 UAC 的情况下运行 Vista 或 7 而导致的微小设计疏忽;使用Run as administrator
我在 OS X 上看到的闪电般的速度启动 Git Bash(或在启动 Git Bash 后使用 oa 网络连接在 7 上 - 请参阅@Gauthier 答案)。
Edit 2: AH HA!See my answer.
编辑2:啊哈!看我的回答。
采纳答案by Kevin L.
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.
在 Vista 或 7 上缓慢的解决方案似乎是使用运行 Git Bash Run as administrator
(或为 Git Bash快捷方式禁用 UAC ...或完全禁用 UAC )。区别是白天和黑夜,在 7 上使用 git 再次很棒。
This appears to be related to a known issueand, as I speculated, XP as a development environment for msysgitis partially responsible.
这似乎与一个已知问题有关,正如我推测的那样,XP 作为 msysgit 的开发环境负有部分责任。
回答by shoelzer
You can significantly speed up Git on Windows by running three commands to set some config options:
您可以通过运行三个命令来设置一些配置选项来显着加快 Windows 上的 Git:
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/
core.preloadindex
并行执行文件系统操作以隐藏延迟(更新:在 git 2.1 中默认启用)core.fscache
修复了 UAC 问题,因此您无需以管理员身份运行 Git(更新:Git for Windows 2.8 默认启用)gc.auto
最小化 .git/ 中的文件数量
回答by chrisxxyy
For me the issue was the use __git_ps1 in the shell prompt - I guess due to slow disk access in msysgit.
对我来说,问题是在 shell 提示中使用 __git_ps1 - 我猜是由于 msysgit 中的磁盘访问速度慢。
Solution was to remove $(__git_ps1) from the PS1=... lines in /etc/profile
解决方案是从 /etc/profile 中的 PS1=... 行中删除 $(__git_ps1)
quick test if this solution applies: in a git shell, type export PS1='$ ' and check the speed of your operations.
快速测试此解决方案是否适用:在 git shell 中,键入 export PS1='$ ' 并检查您的操作速度。
回答by Tom De Leu
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.
在一台新机器上尝试了几乎所有的技巧(包括我的另一个答案中的技巧),但它们没有用,Git 仍然慢得要命。
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 (!).
然后我查看了病毒扫描软件(预装的):我禁用了 McAfee Security Center 的实时扫描,并且 presto:git 现在非常快!“git svn rebase”所需的时间从 30 秒减少到 5 秒(!)。
I hope this is helpful to other people still having issues with slow Git on Windows, I lost hours figuring this out.
我希望这对在 Windows 上仍然遇到缓慢 Git 问题的其他人有帮助,我花了几个小时来弄清楚这一点。
回答by Daniel Hume
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:
唉,“以管理员身份运行”对我不起作用 - 但正如 Kevin L 发现的那样,断开网络适配器,启动 git bash,然后重新连接工作正常。所以我把它封装在一个批处理脚本中,并在我的开始菜单中添加了一个快捷方式,标记为以管理员身份运行:
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)
(Win 7 Professional SP1,Git 版本 1.7.8-preview20111206)
回答by Gauthier
A colleague of mine had this behaviour whenever Outlook was running. Trying killing outlook and test again.
每当 Outlook 运行时,我的一位同事就会出现这种行为。尝试杀死 Outlook 并再次测试。
You could also try to test:
您还可以尝试测试:
- without connection to any network,
- without antivirus running,
- without any other program running.
- 无需连接任何网络,
- 没有运行防病毒软件,
- 没有任何其他程序运行。
回答by Matthew Skelton
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.
我们发现,在某些用户帐户上运行时,单独的 git.exe 实例会在调用 时阻塞WaitForSingleObject()
,因此一次只能有效地运行单个 git.exe 操作。更改用户帐户可以解决此问题。
Details here: https://stackoverflow.com/a/13054022
回答by Alex Brown
I have MacAffee and telling it to exclude the .git directory and all subdirectories from real-time-scanning addressed the performance problem.
我有 MacAffee 并告诉它从实时扫描中排除 .git 目录和所有子目录解决了性能问题。
回答by Frank Yin
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"
搞乱 Windows 7 UAC 的另一种方法可能是在 Program Files 文件夹之外安装 mysysgit。例如,而不是“C:\Program Files (x86)\Git”,尝试在“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.
我尝试摆弄“以管理员身份运行”和 UAC 控件无济于事,但放弃并重新安装。我之前最大速度约为 15KiB/s,但现在超过 60kiB/s。
回答by jwg
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.
如果关闭 UAC 不能提高性能,请尝试关闭 luafv 驱动程序。在尝试了此页面上的几乎所有内容以及几个类似的问题后,这对我有用。Git 已经从无法使用的缓慢变成了相当不错的。
Open 'regedit' and find the registry key
打开“regedit”并找到注册表项
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/services/luafv
Change the value of Start
from 2 to 4.
将值Start
从 2更改为 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.
我在luafv
这里找到了有关如何禁用的详细信息。请注意,我个人不知道是什么luafv
或做什么。该页面给出了关于如果关闭它可能会发生的坏事的各种警告,您可能应该认真对待。
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 :)
编辑:下面的评论指出我以错误的方式得到了这个(链接有正确的方式)。现在已经修复了。对不起那些我破坏了注册表的人:)