不能Git Blame文件

时间:2017-05-22 16:22:11

标签: xcode git git-blame

我在两台独立的笔记本电脑上使用Xcode和这个回购。在一台笔记本电脑上,在Xcode中我可以选择版本编辑器窗格,它向我显示每行的责任信息,例如谁提交了提交以及何时提交。但是,在另一台笔记本电脑上,我总是收到错误could not blame {file}. Error: fatal: no such ref: HEAD

我不确定这意味着什么或如何解决它。当我经常拉,回购应该是非常相似的(除了gitignore差异或其他东西)。所以我不确定一台笔记本电脑上的.git文件夹中是否存在细微差别。我知道HEAD是对某个提交的引用,但除此之外,我不确定如何解决这个问题。

3 个答案:

答案 0 :(得分:0)

"不能责怪":请关掉"责备"编辑。看起来你添加了一个尚未提交的新文件。所以Blame编辑器没有数据显示,它会引发错误,因为"不能责怪"

答案 1 :(得分:0)

回购子文件夹中的某个位置可能还有第二个.git文件夹(至少这是造成我的原因)。 Xcode不支持此功能。

要解决此问题,请转到您的回购根目录:

cd ~/Development/repo

在子文件夹中搜索杂散存储库:

find . -name ".git"

如果输出中没有./.git以外的内容,请将其删除:

rm -rf subfolder/some_folder/.git  

如果此时已运行Xcode,请重新启动它,它应能按预期工作。

答案 2 :(得分:0)

Steps to fix not working blame for line in Xcode: -
1. Go to the project directory first.
2. Fist remove all the git process 
   use this command to find all git process `find . -name ".git"`
3. If there's anything other than ./.git in the output, remove it:
   use this command to remove `rm -rf subfolder/some_folder/.git` 
4. After that, you can delete your project folder and clone the same repo from 
   stash
   use git clone "ssh key for your repo"
5. After cloning the project, an open project you will able to see blame for a 
   line.

In my case this steps resolved the problem, I am not sure that will work for all but at least try it once.
相关问题