GIT 警告: 跳过不精确重命名检测的文件太多

我知道默认的重命名限制是100,我们可以使用配置 diff.renamelimit config来增加这个值

我所担心的是,如果没有设置这个配置,是否会出现错误的合并或任何代码丢失? 我试图合并(git 合并)2分支有巨大的变化。

有人能更清楚地说明一下这个配置设置吗?

69454 次浏览

Your content is safe.

As I understand it, git doesn't actually have any concept of a first-class rename operation (only bzr does, of the big 3 DVCSs): the mv is sugar on top of the underlying machinery, which is basically an add and a rm. Since git can track the content that changes during such operations, though, it can use heuristics to guess when an add and a rm are actually a mv. Since that takes way more work than just displaying what git actually recorded—the docs for rename1explain that it "...require O(n^2) processing time where n is the number of potential rename/copy targets"—git won't try it when too many files are involved. The setting you mention just controls that threshold.

In case this helps anyone, I had a lot of files (hundreds, if not thousands) in one branch, which were not yet in the other branch. Running

$ git config merge.renamelimit 15345

made the below error when merging go away

$ git merge master
.
.
.
warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your merge.renamelimit variable to at least 15345 and retry the command.