git diff认为整个文件在未更改时已更改 [英] git diff sees whole file as changed when it's not
问题描述
git diff引擎看到一个完整文件,但没有更改.例如,进行以下提交:>://github.com/etiago/phpvirtualbox/commit/626e09958384f479f94011ac3b8301bd497 /a>
The git diff engine is seeing a whole file as changed when it has not. For example, take this commit: https://github.com/etiago/phpvirtualbox/commit/626e09958384f479f94011ac3b8301bd497aec51
在这里,我们看到文件 lib/vboxconnector.php 具有2807个添加项和2778个删除项.另外,通过执行手动git diff,我发现确实确实将整个文件删除(标有减号),而将整个新文件当作添加文件.但是,这些文件有很多共同点,而Git只是忽略了这些点.
Here we see that the file lib/vboxconnector.php has 2807 additions and 2778 deletions. Additionally, from doing a manual git diff I find that indeed, the whole file is taken in as a deletion (marked with minus) and a whole new file is taken as an addition. However, the files have a lot in common which Git simply ignored.
我查看了 diff为相同文件返回整个文件,但事实并非如此,因为两次提交之间没有空格变化.
I've looked at diff returning entire file for identical files but it does not seem to be the case as no white space changes exist between the two commits.
此外,获取文件的两次提交(626e09958384f479f94011ac3b8301bd497aec51
和626e09958384f479f94011ac3b8301bd497aec51^1
中的一次提交)并使用Meld进行比较,我得到了正确的差异分析.
Furthermore, taking the two commits of the file (the one in 626e09958384f479f94011ac3b8301bd497aec51
and 626e09958384f479f94011ac3b8301bd497aec51^1
) and diff'ing them using Meld, I get the right diff analysis.
为了方便起见,我已将文件的两次提交上载到我的Dropbox: commit_1 commit_2 .
I've uploaded the two commits of the file to my Dropbox for convenience: commit_1 commit_2.
推荐答案
在vboxconnector.php_1
中,每行以CR
LF
序列终止.
In vboxconnector.php_1
, every line is terminated by a CR
LF
sequence.
在vboxconnector.php_2
中,每行仅由LF
终止.
因此文件的每一行都已更改.
Thus every line of the file has changed.
尝试使用git diff --ignore-space-at-eol
.
您还可以在此问题的答案中找到一些有用的信息.
You may also find some useful information in the answers to this question.
这篇关于git diff认为整个文件在未更改时已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!