Reputation: 2526
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
Upvotes: 15
Views: 11326
Reputation: 1039
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.
Upvotes: 28
Reputation: 2167
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.
Upvotes: 1