What if .gitignore let's you define a pattern basically saying ignore all files considered as binary files? I mean without adding each pattern, because that are too many lines, but instead something like binary, similar to what .gitattributes let's you define.
Basically I would like:
- ignore all files by default, which are considered as
binaryas auto-detected by git and as specified by.gitattributes - allow specific binary files only, by allowing them explicitely with
.gitignoreas usual
I did not yet found any hint that something like this is possible. Does somebody knows more?
This is not possible.
As stated in the gitignore documentation
Therefore it is not possible to ignore files by their kind
A workaround to this could be to define a pre-commit script that checks if there are binary files in your commit and exits with a non-zero code so that you won't be able to commit when binary files are present in the commit.
You could check each file present in the commit and see if it is a binary with this command