在git HEAD中查找所有二进制文件 [英] Find all binary files in git HEAD

查看:271
本文介绍了在git HEAD中查找所有二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个巨大的git repo,最终希望使用 bfg 进行清理。
但首先,我想追踪并删除 HEAD 中git视为二进制文件的文件...



因此,我在寻找的是查找 HEAD 中git视为二进制文件的所有文件



这些都没有帮助:


  • 列出所有文件(非二进制)文件在repo中<我正在寻找二进制文件。而不是文本文件。

  • Git查找所有历史中的二进制文件<我只关心HEAD

  • http://git.661346.n2.nabble.com/git-list-binary-and-or-non-binary-files-td3506370.html <我尝试了这些命令,但他们没有帮助。


    预先感谢您的帮助。


    解决方案

      diff < grep'^>'| cut -d:-f 1 | cut -d''-f 2- 

    打破它:




    • git grep -c''打印存储库中每个文件的名称和行数。添加 -I 选项会使该命令忽略二进制文件。
    • diff<(cmd1)< (cmd2)使用进程替换为命名管道提供 diff ,通过该管道输出 cmd1 cmd2

    • grep cut 命令用于从 diff 的输出中提取文件名。


    I have a huge git repo that eventually want to clean up with bfg.
    But first, I want to track down and remove files in the HEAD which git treats as binary...

    So, what i'm looking for is a command to find all files in the HEAD that git treats as binary.

    These didn't help:

    Thank you in advance for your help.

    解决方案

    diff <(git grep -Ic '') <(git grep -c '') | grep '^>' | cut -d : -f 1 | cut -d ' ' -f 2-
    

    Breaking it down:

    • git grep -c '' prints the names and line counts of each file in the repository. Adding the -I option makes the command ignore binary files.
    • diff <(cmd1) <(cmd2) uses process substitution to provide diff with named pipes through which the output of cmd1 and cmd2 are sent.
    • The grep and cut commands are used to extract the filenames from the output of diff.

    这篇关于在git HEAD中查找所有二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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