git mv和变化以及相似指数
git mv and changes and similarity index
当使用git mv
重命名文件时,提交将显示重命名自和重命名为,并且在拉取请求中显示相同,这很好。但是当一个文件被git mv
ed然后改变时,看起来有一个特定的阈值,当改变的行数超过它时,它将不再显示为重命名,而是显示为删除旧文件并添加新文件.所以我的问题是这个阈值是一个明确定义的数字吗?有没有其他方法可以让它变得更好,主要是因为在pull request diff中,当两个文件不考虑重命名时,diff不会并排显示,这使得审查困难。
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
重命名文件时,提交将显示重命名自和重命名为,并且在拉取请求中显示相同,这很好。但是当一个文件被git mv
ed然后改变时,看起来有一个特定的阈值,当改变的行数超过它时,它将不再显示为重命名,而是显示为删除旧文件并添加新文件.所以我的问题是这个阈值是一个明确定义的数字吗?有没有其他方法可以让它变得更好,主要是因为在pull request diff中,当两个文件不考虑重命名时,diff不会并排显示,这使得审查困难。
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
becomes0.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一个文件,提交,然后做一些修改。
两者都可以,据说与文件的其余部分相比,修改很小(典型情况:仅更改包名称的重构)