如何找到引入给定树的提交哈希?

时间:2018-04-12 12:29:19

标签: git

我有一个破碎的树,其中包含

给出的哈希值
$ git fsck
Checking object directories: 100% (256/256), done.
warning in tree <tree-hash>: nullSha1: contains entries pointing to null sha1

我希望找到引入它的提交。 我知道如果我尝试过滤分支,我可以找到该信息,例如:

$ git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch <my_broken_subdir>' --prune-empty --tag-name-filter cat -- --all
...
Rewrite <commit_hash> error:
    cache entry has null sha1: <my_broken_subdir>

但是,我有一个历史悠久的项目,运行git-filter需要很长时间。

  

更新

实际上,树被破坏了它包含一个空sha1。因此,git bisect将不起作用,因为在我检查的任何提交中,运行

 git fsck

总是会给我

warning in tree <tree-hash>: nullSha1: contains entries pointing to null sha1

1 个答案:

答案 0 :(得分:1)

一般来说,尝试通过提交找到一个树听起来并不好玩,因为“破坏的”var str = 'this $is a _test@#$%'; str = str.replace(/[\W_]+/g,' '); console.log(str);可能位于任何给定提交的var str = 'this $is a _test@#$%'; str = str.replace(/[\W_]+/g,' '); var res = str.split(' ').map((s) => s.charAt(0).toUpperCase() + s.substr(1)).join(' '); console.log(res);层次结构中的任何位置。听起来好像你可能知道相应的目录路径,这会简化一些事情,但这仍然听起来像是一个非常复杂的自定义脚本。

使用TREETREE(查找错误)作为每次提交的测试可能更简单。

相关问题