简体   繁体   English

在Git中悬空提交中搜索字符串

[英]Search for string in dangling commits in Git

The following monstrosity very nicely found a git stash containing the word Upload which is what I was looking for: 以下怪物很好地找到了一个git stash,其中包含我要查找的单词Upload:

git fsck --no-reflog | awk '/dangling commit/ {print $3}' | \
while read ref; do if [ "`git show -p $ref|grep -c Upload`" -ne 0 ]; then echo $ref ; fi ; done 

Is there a prettier version of this? 有更漂亮的版本吗? I guess the pickaxe should work but git log -g doesn't see this commit. 我猜镐应该工作,但是git log -g没有看到这个提交。

... but git log -g doesn't see this commit ...但是git log -g没有看到这个提交

Commits that are (still) referenced by the reflog are considered reachable and not dangling. 引用日志(仍然)引用的提交被认为是可到达的而不是悬空的。 Thus running git log –g is contrary to what you wanted, so no surprises here. 因此,运行git log –g与您想要的相反,因此这里没有任何意外。

Commits will be reachable via reflog for the gc.reflogExpire timespan, with a default of 90 days. 对于gc.reflogExpire时间跨度,可通过reflog达到承诺,默认为90天。

Is there a prettier version of this? 有更漂亮的版本吗?

No, git fsck is the right way for accessing dangling commits. 不, git fsck是访问悬挂提交的正确方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM