# .gitattributes and defaulting to binary

2 messages from 2013-09-16 to 2013-09-16. Participants: Matthieu Vachon, Jeff King.
Thread: https://gitlist.dev/t/34942

## Matthieu Vachon, 2013-09-16 21:35

Subject: .gitattributes and defaulting to binary
Message-ID: <CAOTvmonjWtUM42ATpEu+s6GVcpTO10BT0izXVB_aqK2npgRfWQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAOTvmonjWtUM42ATpEu%2Bs6GVcpTO10BT0izXVB_aqK2npgRfWQ%40mail.gmail.com

```
Hi all,

I would like to craft my `.gitattributes` in a way that all files
expect those specified in it are treated as binary from a line-ending
normalization point of view (and diff viewing).

But I was not able to achieve it right now. When having this in my
`.gitattributes`, git treats all files as binary, even the one
explicitly specified like `*.txt`:

    *.txt text
    * binary

I tried with:

    *.txt text
    * -text

And it does not seem to work correctly neither because then, my
`test.txt` file is not having correct line ending when setting
`core.eol` to `crlf` (or using `eol=crlf` in the `.gitattributes`
file).

So, is it possible to do something like that? If yes, is my sample
`.gitattributes` should work?

Regards,
Matt

```

## Jeff King, 2013-09-16 22:09

Subject: Re: .gitattributes and defaulting to binary
Message-ID: <20130916220908.GC5477@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20130916220908.GC5477%40sigill.intra.peff.net
In-Reply-To: <CAOTvmonjWtUM42ATpEu+s6GVcpTO10BT0izXVB_aqK2npgRfWQ@mail.gmail.com>

```
On Mon, Sep 16, 2013 at 05:35:24PM -0400, Matthieu Vachon wrote:

> But I was not able to achieve it right now. When having this in my
> `.gitattributes`, git treats all files as binary, even the one
> explicitly specified like `*.txt`:
> 
>     *.txt text
>     * binary

>From "git help attributes":

  When more than one pattern matches the path, a later line overrides an
  earlier line. This overriding is done per attribute.

Reversing the two lines should do what you want.

You may also want to use "-text" instead of "binary"; the latter also
implies "-diff", which means you will never see diffs of those files,
even if they are actually text.

-Peff

```
