Git责备没有历史

时间:2011-01-09 09:26:34

标签: git msysgit blame

当我在文件上运行git blame(使用msysgit)时,我总是得到以下类型的打印输出:

00000000 (Not Committed Yet 2011-01-09 11:21:30 +0200   1) package co
00000000 (Not Committed Yet 2011-01-09 11:21:30 +0200   2) {
00000000 (Not Committed Yet 2011-01-09 11:21:30 +0200   3)      impor
00000000 (Not Committed Yet 2011-01-09 11:21:30 +0200   4)      impor
00000000 (Not Committed Yet 2011-01-09 11:21:30 +0200   5)      impor
00000000 (Not Committed Yet 2011-01-09 11:21:30 +0200   6)      impor
00000000 (Not Committed Yet 2011-01-09 11:21:30 +0200   7)      impor

即。它显示所有行都没有提交。

我在许多文件上尝试了这个,它有很多提交 - 总是相同的结果。我也试过使用相对/完整路径,但它似乎没有区别。

当我尝试使用TortoiseGit时,它总是将每一行显示为在第一次提交时最后一次提交:

alt text

甚至认为,正如我所说,这些文件的历史实际上有数十次提交..

想法?

修改 - 更多信息

  • Git blame在GitHub上运行正常,这个回购托管在这里。
  • 如果我将它克隆到linux机器并且责备那里
  • ,它也可以正常工作
  • 似乎只在msysgit上这不起作用

4 个答案:

答案 0 :(得分:125)

git blame file.txt将工作副本中的file.txt版本归咎于该文件。如果file.txt在repo中有Windows换行符(CRLF)并且您有core.autocrlf = true,则file.txt的每一行都将被视为不同,并且git blame将报告为尚未提交。< / p>

git blame <my_branch>(或更好的git blame HEAD,无论你在哪个分支上工作)的原因在于它不会归咎于工作副本版本,因此没有潜力尚未提交的行。

答案 1 :(得分:55)

找到解决方案 - 非常奇怪。

如果我这样做:

git blame file.txt

历史被打破,如上所述。

如果我改为:

git blame my_branch file.txt

有效!

这很奇怪,因为AFAICS的用法不需要​​分支名称:

$ git blame
usage: git blame [options] [rev-opts] [rev] [--] file

答案 2 :(得分:7)

启动git 2.0.1(2014年6月25日),git blame应停止报告所有“尚未提交”的行。

commit 4d4813abrian m. carlson (bk2204)(2014年4月26日) (由Junio C Hamano -- gitster --合并于commit e934c67,2014年6月6日)

  

blame:正确处理文件而不管autocrlf

     

如果文件在CRLF的存储库中包含core.autocrlf=input行结尾,则责备始终将行标记为“Not Committed Yet”,即使它们未经修改也是如此。
  在创建虚假提交时不要尝试转换行结尾,以便无论autocrlf设置如何,blame都能正常工作。

答案 3 :(得分:1)

另一种可能性:区分大小写的文件名错误

我遇到了与git blame file.txt相同的问题,然后意识到我用file.txt做了一个区分大小写的文件名错误

将其更改为File.txt(例如),我得到了预期的结果,无需指定my_branch:git blame File.txt

相关问题