简体   繁体   English

Git 在 Windows 10 上慢得无法使用

[英]Git is Unusably Slow on Windows 10

I have a Windows 10 laptop with SSD, 16GB of RAM, and an i7 processor.我有一台带 SSD、16GB 内存和 i7 处理器的 Windows 10 笔记本电脑。

I have read this thread and none of the solutions helped.我已阅读此线程,但没有任何解决方案有帮助。 Git/Bash is extremely slow in Windows 7 x64 Git/Bash 在 Windows 7 x64 中非常慢

I have tried using Git in the following scenarios:我曾尝试在以下场景中使用 Git:

  1. Command Prompt命令提示符
  2. Git Bash Shell Git Bash Shell
  3. Visual Studio 2015视觉工作室 2015
  4. Source Tree源树

All of them are pretty much unusable.所有这些都几乎无法使用。 For example, before I started typing this question I ran the following command from the Command Prompt:例如,在我开始输入这个问题之前,我从命令提示符运行了以下命令:

git flow feature start "Separate_Cash_Incentives" git flow 功能启动“Separate_Cash_Incentives”

It has been running for over 10 minutes and has not completed yet.它已经运行了10多分钟,还没有完成。

When I look at my task manager, my CPU is at 10%, my memory is at 40%, and my disk is at 5%.当我查看我的任务管理器时,我的 CPU 为 10%,我的内存为 40%,我的磁盘为 5%。

There are currently 10 "Git for Windows" processes running and all of them say 0% CPU.当前有 10 个“Windows 版 Git”进程在运行,并且所有进程都表示 CPU 占用率为 0%。

How can I fix this problem?我该如何解决这个问题?

Thanks!谢谢!

EDIT: It appears that the majority of the slowness happens when creating or merging branches.编辑:似乎大部分缓慢发生在创建或合并分支时。 Just doing a simple commit or push is pretty fast.只是做一个简单的提交或推送是相当快的。

Just for testing, try and仅用于测试,尝试并

Try and:尝试并:

  • unzip PortableGit-2.12.2.2-64-bit.7z.exe (if you have a Windows 64 bits) anywhere you want.PortableGit-2.12.2.2-64-bit.7z.exe (如果您有 Windows 64 位)解压缩任何您想要的位置。
    For instance: C:\\git\\2.12.2.2例如: C:\\git\\2.12.2.2
  • open a regular CMD console and set a PATH to:打开常规 CMD 控制台并将 PATH 设置为:

     set PATH=C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\ set PATH=%PATH%;C:\\git\\2.12.2.2\\bin;C:\\git\\2.12.2.2\\cmd;C:\\git\\2.12.2.2\\usr\\bin;C:\\git\\2.12.2.2\\mingw64\\bin

Then type bash -l -i and see if Git is still slow.然后输入bash -l -i看看 Git 是否仍然很慢。

The goal is to make sure you don't have any conflicts with other software in your PATH .目标是确保您与PATH其他软件没有任何冲突。

Also, try and (for testing) turn out that your anti-virus to see if there is any side-effect here.此外,尝试并(用于测试)证明您的防病毒软件是否有任何副作用。

Finally, make sure your codebase is on your local drive (not accessed through the network or shared mounted folder)最后,确保您的代码库在您的本地驱动器上(不是通过网络或共享安装文件夹访问)

It remains to be tested if a simple exception rule (for instance on the git installation folder) would be enough for git to run normally (ie, if the AV is set to not check its git installation folder).一个简单的例外规则(例如在 git 安装文件夹上)是否足以让 git 正常运行(即,如果 AV 设置为检查其 git 安装文件夹)还有待测试。


It appears that the majority of the slowness happens when creating or merging branches.看起来大部分缓慢发生在创建或合并分支时。

Speaking of merge, Git 2.28 (Q3 2020) will include some code optimization for a common case.说到合并,Git 2.28(2020 年第三季度)将包含一些针对常见情况的代码优化。

See commit 8777616 (19 May 2020) by Andrew Ng ( andrewyng ) .请参阅Andrew Ng ( andrewyng ) 提交的 8777616 (2020 年 5 月 19 日)
(Merged by Junio C Hamano -- gitster -- in commit 0739479 , 02 Jun 2020) (由Junio C gitster合并-- gitster -- in commit 0739479 ,2020 年 6 月 2 日)

merge : optimization to skip evaluate_result for single strategy merge :优化以跳过单个策略的evaluate_result

Signed-off-by: Andrew Ng签字人:Andrew Ng

For a merge with a single strategy, the result of evaluate_result() is effectively not used and therefore is not needed, so avoid altogether.对于单个策略的合并, evaluate_result()的结果实际上没有被使用,因此不需要,所以完全避免。

On Windows, this optimization can halve the time required to perform a recursive merge of a single commit with the LLVM repo.在 Windows 上,此优化可以将执行单个提交与 LLVM 存储库的递归合并所需的时间减半

您可以在完全卸载后尝试重新安装 git,然后尝试在 git bash 中运行这些命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM