如何过滤"git fsck --unreachable"的结果 [英] How can I filter the results of 'git fsck --unreachable'
问题描述
我正在尝试查找使用某些文件somefile.jsx
的无法到达的提交.我可以那样做吗?还是可以在其中一个文件中查找包含特定特定内容的文件?更深层的问题是我有数百个无法到达的提交,我正在寻找一个..
I'm trying to look for unreachable commits that use certain file somefile.jsx
, say. Can I do that? Or can I look for ones that contain a certain specific in one of the files? The deeper problem I have hundreds of unreachable commits there's one I'm looking for ..
推荐答案
- 运行
git fsck --unreachable --no-progress
以仅获取包含提交信息的行. - 使用Grep进行提交,
grep 'unreachable commit'
. - 将其放置到
cut -d' ' -f3
以获得提交(第三字段).
- Run
git fsck --unreachable --no-progress
to get just the lines with the commit info. - Grep it for just commits,
grep 'unreachable commit'
. - Pipe it to
cut -d' ' -f3
to get the commit it (the 3rd field).
将所有内容放在一起...
Putting that all together...
git fsck --unreachable --no-progress | grep 'unreachable commit' | cut -d' ' -f3
现在,您有了所有无法访问的提交的列表.将其放入文件中.
Now you have a list of all the unreachable commits. Put that in a file.
您可以在每个文件上运行git --no-pager log --format=oneline -n1 --stat <commit id>
来查看它们更改了哪些文件.这是一些Perl的单行代码.
You can run git --no-pager log --format=oneline -n1 --stat <commit id>
on each of them to see what files they changed. Here's a little Perl one-liner to do that.
perl -nwle 'system "git --no-pager log --format=oneline -n1 --stat $_"' <commit file>
您甚至可以为"WIP"使用grep查找旧藏匿处.
You can even grep for "WIP" to find old stashes.
这篇关于如何过滤"git fsck --unreachable"的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!