【问题标题】:GitHub - why two lines are marked as different without any visible differences?GitHub - 为什么两行被标记为不同而没有任何明显的差异?
【发布时间】:2016-08-01 12:40:19
【问题描述】:

这是commit cba438 on Github

如您所见,index.html 中的第 1 行被标记为已更改:

但正如我所见,没有一个单一的角色改变。是 GitHub 还是 Git?是bug还是某个隐藏字符被改变了?

【问题讨论】:

  • 这可能是行尾或空格。我认为是 Git,GitHub 很可能只是这里的一个旁观者。

标签: git github diff git-diff


【解决方案1】:

是的,那里有一个隐藏字符,UTF8 BOM

$ git show cba438:index.html | od -c | head -1
0000000 357 273 277   <   !   d   o   c   t   y   p   e       h   t   m
$ git show cba438~1:index.html | od -c | head -1
0000000   <   !   d   o   c   t   y   p   e       h   t   m   l   >  \n

相关SO问题:What's different between UTF-8 and UTF-8 without BOM?

【讨论】:

  • 感谢 Wumpus 提供命令行解释的好答案。
【解决方案2】:

在删除行的末尾看起来像一个空格。

【讨论】:

  • 这很奇怪。我很确定我的代码中没有尾随空格,因为我在 Sublime Text 中启用了"trim_trailing_white_space_on_save": true。另外,如果是空格,GitHub 不应该这样标记它:i.imgur.com/5KIR6fU.png
猜你喜欢
  • 2011-06-11
  • 1970-01-01
  • 2022-11-06
  • 2018-10-10
  • 2013-04-24
  • 1970-01-01
  • 2018-12-10
  • 2012-03-04
  • 1970-01-01
相关资源
最近更新 更多