Change threshold on the similarity index for git merge with renaming involved (like -M[n] --find-renames[=n] on diff)

孤者浪人 提交于 2019-12-04 19:21:23

问题


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

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

diff.renames Tells 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 The number of files to consider when performing rename detection during a merge; if not specified, defaults to the value of diff.renameLimit.

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

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

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.

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?


回答1:


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

git merge -X rename-threshold=80 branch


来源:https://stackoverflow.com/questions/8826972/change-threshold-on-the-similarity-index-for-git-merge-with-renaming-involved-l

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!