如何过滤"git fsck --unreachable"的结果 [英] How can I filter the results of 'git fsck --unreachable'

查看:106
本文介绍了如何过滤"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 ..

推荐答案

  1. 运行git fsck --unreachable --no-progress以仅获取包含提交信息的行.
  2. 使用Grep进行提交,grep 'unreachable commit'.
  3. 将其放置到cut -d' ' -f3以获得提交(第三字段).
  1. Run git fsck --unreachable --no-progress to get just the lines with the commit info.
  2. Grep it for just commits, grep 'unreachable commit'.
  3. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆