问题描述
我不确定这种行为是否怪异,但这是正在发生的事情:如果我在文件上运行git blame
,则该文件中来自初始提交的任何行都带有带有前导尖号的SHA( ^
),像这样
I'm not sure if this behavior is bizarre, but here's what's happening: it seems if I run git blame
on a file, any lines in that file that are from the initial commit have a SHA with a leading caret (^
), like this
^bb65026 (Brian Danielak 2012-10-27 19:11:54 -0700 1) hello, world!
bbcd4a96 (Brian Danielak 2012-10-27 19:11:54 -0700 2) hello again!
复制步骤
在终端提示下:
Steps to Reproduce
From a terminal prompt:
mkdir newProject
cd newProject
git init
echo 'hello, world!' >> testFile.txt
git add testFile.txt
git commit -m "Initial Commit"
git blame testFile.txt
然后验证您的责备输出是否像我的一样领先插入符号(尽管您的SHA可能不匹配)
Then verify your blame output has a leading caret, as mine did (though your SHA likely won't match)
^bb65026 (Brian Danielak 2012-10-27 19:11:54 -0700 1) hello, world!
作为测试,您可以尝试在文件中添加第二行并重新提交,以查看只有第一行的哈希包含前导插入符
As a test, you can try adding a second line to a file and re-committing, to see that only the hash of the first line contains a leading caret
echo 'hello again!' >> testFile.txt
git add testFile.txt
git commit -m "Initial Commit"
git blame testFile.txt
现在我的责备输出看起来像这样:
My blame output now looks like this:
^bb65026 (Brian Danielak 2012-10-27 19:11:54 -0700 1) hello, world!
bbcd4a96 (Brian Danielak 2012-10-27 19:11:54 -0700 2) hello again!
任何人都可以解释为什么会发生这种情况,以及我是否应该预料到这种情况?它仅在回购中的第一次提交产生一行时才发生吗?如果是这样,为什么?
Can anyone explain why this happens, and whether I should have expected it? Does it only happen when a line comes from the first commit in a repo? If so, why?
推荐答案
git blame 实际上确实提到了插入符号是用于边界提交"的,看起来他们正在定义类似此blame范围内最古老的提交"的内容-您的案例是项目的初始提交,但是通过一些其他选择,您可能只将责任归咎于3周前的提交.
The docs for git blame actually do mention the caret as being used for a "boundary commit", which it looks like they're defining something like "the oldest commit in this blame range" -- in your case it's the project's initial commit, but with some different options you may have only blamed up to commits from 3 weeks ago.
这篇关于为什么行在git blame视图中的SHA会有一个尖号(^)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!