gpt4 book ai didi

git mv 和变化和相似度索引

转载 作者:行者123 更新时间:2023-12-01 12:08:58 26 4
gpt4 key购买 nike

当使用 git mv 重命名文件时,提交将显示重命名自和重命名为,并且在 pull 请求中显示相同,这很好。但是当一个文件是 git mv ed然后更改,看起来有一定的阈值,当更改的行数超过它时,它将不再显示为重命名,而是显示为删除旧文件并添加新文件。所以我的问题是这个阈值是一个明确定义的数字吗?有没有其他方法可以让它更好,主要是因为在pull request diff中,当两个文件不被考虑重命名时,diff不会并排显示,这使得审查变得困难。

最佳答案

它基于 diff similarity index

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.

Without a % sign, the number is to be read as a fraction, with a decimal point before it. I.e., -M5 becomes 0.5, and is thus the same as -M50%.
Similarly, -M05 is the same as -M5%.

To limit detection to exact renames, use -M100%.

The default similarity index is 50%.



更一般地说,最好先 mv/rename 一个文件,提交,然后做一些修改。
如果与文件的其余部分相比,修改很小,则您可以同时执行这两种操作(典型情况:仅在包名称发生变化的情况下进行重构)

关于git mv 和变化和相似度索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54085112/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com