Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mark folder as binary in .gitattributes

Tags:

git

github

I have to include some folder to a repository but I don't want my git to modify it's content (line endings etc)

I already have some files that are marked as binary files in .gitattributes i.e. images:

*.png binary

but this rule specifies certain category of files - png files, however I want to achieve something like that:

/folder_which_i_want_to_mark_as_binary binary
like image 612
Andrey Yaskulsky Avatar asked Aug 03 '16 10:08

Andrey Yaskulsky


1 Answers

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.

like image 187
emmenlau Avatar answered Oct 02 '22 11:10

emmenlau