Git Blame 没有显示任何历史记录

发布于 2024-10-11 05:49:16 字数 989 浏览 3 评论 0原文

当我在文件上运行 gitblame(使用 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 上这不起作用

When I run git blame on a file (using msysgit) I always get the following sort of printout:

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

i.e. it shows all lines as Not Yet Committed.

I tried this on many files, that have many commits - always the same results. I also tried using relative/full path, but it seems to make no difference.

When I try to use TortoiseGit's blame it always shows every line as being last committed at the first commit:

alt text

even thought, as I've said, there are actually tens of commits in the history of these files..

Ideas?

Edit - More Info

  • Git blame works fine on GitHub, where this repo is hosted.
  • It also works fine if I clone it to a linux machine and do the blame there
  • It seems that only on msysgit this doesn't work

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

等往事风中吹 2024-10-18 05:49:17

从 git 2.0.1(2014 年 6 月 25 日)开始,gitblame 应该停止报告所有那些“尚未提交”的行。

请参阅 commit 4d4813a(2014 年 4 月 26 日),作者:brian m.卡尔森 (bk2204)
(由 Junio C Hamano -- gitster -- 合并于 提交 e934c67,2014 年 6 月 6 日)

blame:正确处理文件,无论autocrlf

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



radon8472 添加了 评论

答案是git Blame -w(忽略空格)。
原因是我的受责备文件的 textconv 正在使用 Windows 换行符,而 gitblame 似乎不喜欢它,如 kusma答案

Starting git 2.0.1 (June 25th, 2014), git blame should stop reporting all those "Not Yet Committed" lines.

See commit 4d4813a (26 Apr 2014) by brian m. carlson (bk2204).
(Merged by Junio C Hamano -- gitster -- in commit e934c67, 06 Jun 2014)

blame: correctly handle files regardless of autocrlf

If a file contained CRLF line endings in a repository with core.autocrlf=input, then blame always marked lines as "Not Committed Yet", even if they were unmodified.
Don't attempt to convert the line endings when creating the fake commit so that blame works correctly regardless of the autocrlf setting.


radon8472 adds in the comments:

the answer was git blame -w (iggnore whitespace).
The reason was that the textconv for my blamed file was working with windows linebreaks, and git blame seems to not like it, as mentioned in kusma's answer.

流星番茄 2024-10-18 05:49:17

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

我对 git irrelevant file.txt 遇到了同样的问题,然后意识到我用 file.txt 做了区分大小写的文件名拼写错误

将其更改为 File.txt (例如),然后我获得了预期结果,无需指定 my_branch: gitblame File.txt

Another possibility: case-sensitive filename typo

I had the same problem with git blame file.txt, then realized that I'd made a case-sensitive filename typo with file.txt

Changed it to File.txt (for example), and I got the expected results w/o having to specify my_branch: git blame File.txt

寄风 2024-10-18 05:49:16

git Blame file.txt 归咎于工作副本中 file.txt 的版本。如果 file.txt 在存储库中包含 Windows 换行符 (CRLF),并且您有 core.autocrlf = true,则 file.txt 的每一行将被视为不同,并由 git 报告归咎于尚未提交。

git Blanch(或者更好的 git Blanch HEAD,无论你在哪个分支上都可以)起作用的原因是它不工作归咎于工作副本版本,因此不可能出现尚未提交的行。

git blame file.txt blames the version of file.txt in your working copy. If file.txt has Windows-newlines (CRLF) in the repo and you have core.autocrlf = true, then every line of file.txt will be considered different and will be reported by git blame as not yet committed.

The reason why git blame <my_branch> (or even better git blame HEAD, which works no matter what branch you're on) works, is that it doesn't blame the working copy version so there's no potential for lines not yet being committed.

你不是我要的菜∠ 2024-10-18 05:49:16

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

如果我运行此命令:

git blame file.txt

历史记录已被破坏,如上面发布的。

如果我这样做:

git blame my_branch file.txt

它有效!

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

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

Found the solution - very weird.

If I run this:

git blame file.txt

The history is broken, as posted above.

If I do this instead:

git blame my_branch file.txt

It works!

This is very weird, because AFAICS the usage doesn't require a branch name:

$ git blame
usage: git blame [options] [rev-opts] [rev] [--] file
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文