# git list binary and/or non-binary files?

3 messages from 2009-08-24 to 2009-08-24. Participants: skillzero@gmail.com, Johan Herland.
Thread: https://gitlist.dev/t/20724

## skillzero@gmail.com, 2009-08-24 21:50

Subject: git list binary and/or non-binary files?
Message-ID: <2729632a0908241450m1651c77ata9744058c5d42672@mail.gmail.com>
URL: https://gitlist.dev/e/2729632a0908241450m1651c77ata9744058c5d42672%40mail.gmail.com

```
Is there a way to list the files git considers binary in a repository
(and alternatively, the ones it considers text)? I have a large
repository and I want to fix line endings for text files that were
accidentally checked in using CRLF and can't just use the file
extension alone because some files with the same extension may be
binary and others not (e.g. UTF-8 .strings file is text, but a UTF-16
.strings file is binary...git already figured out based on the content
that one is binary).

I thought maybe git ls-files, but I didn't see anything in there I can
use for binary vs text.

```

## Johan Herland, 2009-08-24 22:14

Subject: Re: git list binary and/or non-binary files?
Message-ID: <200908250014.03585.johan@herland.net>
URL: https://gitlist.dev/e/200908250014.03585.johan%40herland.net
In-Reply-To: <2729632a0908241450m1651c77ata9744058c5d42672@mail.gmail.com>

```
On Monday 24 August 2009, skillzero@gmail.com wrote:
> Is there a way to list the files git considers binary in a repository
> (and alternatively, the ones it considers text)? I have a large
> repository and I want to fix line endings for text files that were
> accidentally checked in using CRLF and can't just use the file
> extension alone because some files with the same extension may be
> binary and others not (e.g. UTF-8 .strings file is text, but a UTF-16
> .strings file is binary...git already figured out based on the content
> that one is binary).
>
> I thought maybe git ls-files, but I didn't see anything in there I can
> use for binary vs text.

I use the following to list files that contain CRs, but that are not 
considered binary by Git:

  git grep --cached -I -l -e $'\r'

'git help grep' explains all the options...


Have fun! :)

...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

```

## skillzero@gmail.com, 2009-08-24 22:39

Subject: Re: git list binary and/or non-binary files?
Message-ID: <2729632a0908241539l7243c9a4v170e14140b45cb0b@mail.gmail.com>
URL: https://gitlist.dev/e/2729632a0908241539l7243c9a4v170e14140b45cb0b%40mail.gmail.com
In-Reply-To: <200908250014.03585.johan@herland.net>

```
On Mon, Aug 24, 2009 at 3:14 PM, Johan Herland<johan@herland.net> wrote:

> I use the following to list files that contain CRs, but that are not
> considered binary by Git:
>
>  git grep --cached -I -l -e $'\r'

Thanks, that's what I needed. I needed it to build a list to pass to a
script so I used 'git grep -I --name-only -z -e "" | xargs -o ...'

```
