我在一台位于NFS上的Linux机器上有一个10 GB的仓库.第一次git status需要36分钟,之后git status需要8分钟.似乎Git依赖于操作系统来缓存文件.只有第一个git命令commit,status包括打包/重新包装整个回购需要很长时间才能获得巨大的回购.我不确定你是否曾经使用git status过这么大的回购,但有没有人遇到过这个问题?
我已经试过git gc,git clean,git repack但所花费的时间仍是/几乎是相同的.
子模块或任何其他概念,比如将repo打成较小的那些有帮助吗?如果是这样,那么最好分割更大的回购.有没有其他方法可以改善大型仓库上git命令的时间?
我的 Git 存储库中有几个具有功能的分支。
每个功能都是一些外部存储库,作为子模块插入。
我应该怎么做来纠正分支之间的切换,有和没有子模块?
例子:
$ git init
$ git commit -m "empty" --allow-empty
$ git checkout -b feature
$ git submodule init
$ git submodule add git://feature.git feature
$ git commit -a -m "add feature"
$ git checkout master
warning: unable to rmdir feature: Directory is not empty
Run Code Online (Sandbox Code Playgroud)
我们的master分支工作目录中有一个功能。
如何防止这种情况?
假设项目长时间没有添加和提交.我这样做git add .但是花了太多时间.我想估计当前案例中哪些文件/目录最贵.我有一个好.gitignore文件,但是有时候,我有太多和/或太难以添加并致力于Git的东西.
我的目录中经常有大小从300GB到2TB的目录.虽然通过排除他们directory/*和directory/在.gitignore中,除了速度慢.
如何估计哪些目录/文件过于昂贵而无法提交?
最近我一直在使用 git stash 很多次,我一直在想它真的很慢,即使在一个只有一个文件的新存储库上也是如此。我读过这个问题,大约GIT中藏匿缓慢而这另一个而想尽回答这些问题,但没有任何实际工作。
例如,我已经完成了以下步骤来重现它:
git inittouch file.txtvim file.txt (编辑文件添加 2 行)git add .git commit -m "Initial commit"vim file.txt (再次编辑添加1行)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
Run Code Online (Sandbox Code Playgroud)
8 秒存储一条线的时间太长了。现在使用 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 …Run Code Online (Sandbox Code Playgroud) git提供了一个feature.manyFiles旨在使大型存储库中的体验变得流畅的选项。对于中小型存储库打开它会产生什么后果,例如:
git config --global feature.manyFiles true
Run Code Online (Sandbox Code Playgroud)