"--tree-filter"和"--tree-filter"之间有什么区别?和"--index-filter"在"git filter-branch"中? [英] What is the difference between "--tree-filter" and "--index-filter" in the "git filter-branch"?

查看:185
本文介绍了"--tree-filter"和"--tree-filter"之间有什么区别?和"--index-filter"在"git filter-branch"中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从这个地方学习树"和索引":通过示例学习Git内部原理

I learn "tree" and "index" from the this aritcle: Learning Git Internals by Example

但是当涉及到"git filter-branch"命令时,我不知道"--tree-filter"和"--index-filter"之间有什么区别.

but when it come to "git filter-branch" command, I don't know what is the difference between "--tree-filter" and "--index-filter".

推荐答案

简短的版本是--tree-filter将每个提交检出到一个临时目录中,运行您的filter命令,并根据现在的内容构建一个新的提交.临时目录;而--index-filter将每个提交复制到索引中,运行您的filter命令,并根据索引中的内容构建一个新的提交.

The short version is that --tree-filter checks out each commit into a temporary directory, runs your filter command, and builds a new commit from whatever is now in the temporary directory; while --index-filter copies each commit into the index, runs your filter command, and builds a new commit from whatever is now in the index.

将提交复制到索引要比检出提交快 1 .从索引构建提交比从目录构建提交要快.结果,使用索引过滤器比使用树过滤器快得多.不过,编写脚本并不容易.

Copying a commit to the index is much1 faster than checking out the commit. Building a commit from the index is faster than building a commit from a directory. As a result, using the index filter is much faster than using the tree filter. It's not as easy to script for, though.

1 确切的速度差异取决于您的临时目录:内存中的文件系统比on-SSD上的文件系统快,后者比on-spining-media上的速度快,因此您可以获得更多如果您使用旋转媒体,则可以将树过滤器指向内存中的文件系统.但是即使那样,索引过滤器仍然更快.

1The exact speed difference depends on your temporary directory: an in-memory file system is faster than an on-SSD file system which is faster than on-spinning-media, so you gain more if you're using spinning media than if you can point the tree filter to an in-memory file system. But even then the index filter is still faster.

在实际的磁盘上,我看到大约100倍(因此,需要2分钟的索引过滤器转换为需要3个小时以上的树形过滤器).

On actual disks, I've seen about a factor of 100 or so (hence an index filter that takes 2 minutes translates to a tree filter that takes 3+ hours).

这篇关于"--tree-filter"和"--tree-filter"之间有什么区别?和"--index-filter"在"git filter-branch"中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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