mark folder as binary in .gitattributes

In order to fix line endings you can apply following instructions

UNIX System

git config --global core.autocrlf input

Windows System

git config --global core.autocrlf true

Alternatively (in .gitattributes)

If you want to treat as binary everything in a particular folder, in .gitattributes you could add something like

*.sh text eol=lf
*.bat text eol=crlf
folder/* binary 

Note: folder must be the name of your folder.


The currently accepted answer did not work for me. Possibly the behavior changed in recent versions of git. Quoting from the manual of gitattributes:

The rules by which the pattern matches paths are the same as in .gitignore files (see gitignore[5]), with a few exceptions:

  • negative patterns are forbidden
  • patterns that match a directory do not recursively match paths inside that directory (so using the trailing-slash path/ syntax is pointless in an attributes file; use path/** instead)

Therefore, to treat a whole folder as binary, use the following syntax:

folder_which_i_want_to_mark_as_binary/** binary

Tested with git version 2.20.1.

Tags:

Git

Github