本文介绍了git合并的相似性索引的更改阈值(涉及重命名)(例如diff上的-M [n] --find-renames [= n])的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于diff(logshow)和merge期间的重命名检测启发式,我们有一些配置选项:

We have some configuration options for the rename detection heuristics during diff (log, show) and merge:

diff.renameLimit 执行复制/重命名检测时要考虑的文件数;等同于git diff选项-l.

diff.renameLimitThe number of files to consider when performing the copy/rename detection; equivalent to the git diff option -l.

差异重命名告诉git检测重命名.如果设置为任何布尔值,它将启用基本的重命名检测.如果设置为份数"或副本",它也会检测到副本.

diff.renamesTells git to detect renames. If set to any boolean value, it will enable basic rename detection. If set to "copies" or "copy", it will detect copies, as well.

merge.renameLimit 合并期间执行重命名检测时要考虑的文件数;如果未指定,则默认为diff.renameLimit的值.

merge.renameLimitThe number of files to consider when performing rename detection during a merge; if not specified, defaults to the value of diff.renameLimit.

我们还有一个选项来控制何时将具有不同内容的文件视为diff(logshow)的重命名:

Also we have an option to control when files with different contents are considered a rename for diff (log, show):

-M [&n; n]] (或--find-renames [=< n>]])

-M[<n>](or --find-renames[=<n>])

检测重命名.如果指定了n,则它是相似度索引的阈值(即,与文件大小相比的添加/删除数量).例如,-M90%表示如果文件的90%以上没有更改,则git应该将删除/添加对视为重命名.

Detect renames. If n is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to the file’s size). For example, -M90% means git should consider a delete/add pair to be a rename if more than 90% of the file hasn’t changed.

问题:如何控制相似度索引的阈值以进行合并?它似乎仅可作为diff和其他一些命令行选项使用,而不能用作merge.而且即使diff也没有配置密钥.由于某些原因,它不适用于merge吗?

QUESTION: How to control a threshold on the similarity index for merge? It seems to be available only as a command-line option for diff and some others but not merge. And no configuration key even for diff. Is it not applicable for merge for some reason?

推荐答案

如果要与递归合并策略(默认)合并,则可以使用重命名阈值选项:

If you're merging with the recursive merge strategy (default) you can use the rename-threshold option:

git merge -X rename-threshold=80 branch

这篇关于git合并的相似性索引的更改阈值(涉及重命名)(例如diff上的-M [n] --find-renames [= n])的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 02:16