doulu1914 2015-04-03 08:42
浏览 110
已采纳

Git diff没有任何意义

When I run git diff on a PHP file that I have modified, it shows me the wrong line being modified and the other lines are 'unmodified' (no changes), even though I have modified the other lines.

An example: git diff result

This is the change I have made to the document: enter image description here

It only occurs on certain files and on other occasions, it will sometimes add the other lines, but it does not mark the appropriate line deletions. On other occasions, it will just append the changes at the end of the file, without marking it as an addition.

On SourceTree, it seems that the same diff does not make any sense too: enter image description here

FYI: The files were originally downloaded from a Linux server.

  • 写回答

2条回答 默认 最新

  • dongzhenyin2001 2015-04-04 16:22
    关注

    I found the solution, after inspecting the offending files.

    It seems that the files that were giving problems had a classic Macintosh CR only end of lines (EOLs) format. Contrast this to Window's CR+LF or UNIX's (and derivatives, including OS X) LF. Converting the file to Windows/UNIX EOL format, committing the fixed EOL files remedied the problem.

    Testing it out with a test Git repository proved my suspicions right.

    It might happen to be Git's way of tracking file changes, only supporting CR in combination with LF (CR+LF) and not CR alone (as what classic Mac uses).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题