与Libgit2相比,Windows上的Git隐藏极慢 [英] Git stash on windows extremly slow compared to Libgit2

查看:212
本文介绍了与Libgit2相比,Windows上的Git隐藏极慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我已经多次使用git stash,并且我一直认为它确实很慢,即使在具有单个文件的新存储库中也是如此.我已阅读此问题有关git stash缓慢和

Recently I've been using git stash many times and I've been thinking that it is really slow, even on a new repository with a single file. I've read this question about git stash slowness and this other one and tried every answer to these questions but nothing actually works.

例如,我已完成以下步骤来重现它:

For example I've done the following steps to reproduce it:

  1. git init
  2. touch file.txt
  3. vim file.txt(编辑文件,添加2行)
  4. git add .
  5. git commit -m "Initial commit"
  6. vim file.txt(再次编辑,添加1行)
  7. time git stash
  1. git init
  2. touch file.txt
  3. vim file.txt (edit the file adding 2 lines)
  4. git add .
  5. git commit -m "Initial commit"
  6. vim file.txt (edit it again adding 1 line)
  7. time git stash

输出:

$ time git stash
Saved working directory and index state WIP on master: b9454ed Initial commit
HEAD is now at b9454ed Initial commit    
real    0m8.042s
user    0m0.000s
sys     0m0.046s

存储一行仅需要8秒钟的时间. 现在使用libgit2sharp进行测试:

8 seconds for stashing a single line is so much time. Now a test using libgit2sharp:

static void Main(string[] args)
{
    Repository repo=new Repository(@"C:\Users\UserTest\TestGitRepo");

    repo.Stashes.Add(new Signature("test", "test@test.com", new DateTimeOffset(DateTime.Now)), "Stash on master");
}

此代码需要74毫秒来存储相同的更改. 如果Libgit2这么快,那么应该可以加快git stash命令的速度.我怎样才能做到这一点?

This code takes 74ms to stash the same change. If Libgit2 is that fast then it should be possible to speed up git stash command. How can I achieve this?

实际上使用Windows 10 64位和git 2.11 64位.其他git命令(例如status,add,commit等)也可以正常工作.

Actually using windows 10 64bit and git 2.11 64bits. Other git commands (like status, add, commit, etc.) work fine.

更新:我已经更新到git 2.13,现在git stash ...是14,53s ...

UPDATE: I've updated to git 2.13 and now it's 14,53s for git stash...

更新2:我已经更新到git 2.15,并尝试相同的测试time git stash返回real 0m6,553s.还是很慢...

UPDATE 2: I've updated to git 2.15 and trying the same test time git stash returns real 0m6,553s. Still really slow...

推荐答案

自Git 2.22起

从Git 2.22开始,以前的实验功能现在已稳定,是默认选项.

Since Git 2.22 the previously experimental feature is now stable and the default option.

低于Git 2.22

一年后,安装Git 2.19,我已经在git安装过程中看到一个复选框,以启用新的 experimental 内置存储.

One year later, installing Git 2.19 I've seen a checkbox during git installation to enable the new experimental built-in stash.

就我而言,它运行良好,而且我注意到与旧的实现(使用脚本)相比,巨大的性能有所提高,并且实际上与在Linux中使用相同的命令一样快.

In my case it works fine and I've noticed a huge performance improvement compared to the old implementation (which was using a script) and it's actually as fast as using the same command in linux.

这里的结果遵循完全相同的步骤:

Here the results following exactly the same steps:

$ time git stash
Saved working directory and index state WIP on master: 7a29b92 Initial commit

real    0m0,120s
user    0m0,000s
sys     0m0,015s

这篇关于与Libgit2相比,Windows上的Git隐藏极慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆