How can binary files be ignored in git
using the .gitignore
file?
Example:
$ g++ hello.c -o hello
The
.gitignore uses glob programming to filter files, at least on Linux.
I am about to give a coding talk at a Meetup and, in preparation, I made a directory with several subdirectories that are named according to the order I want to present them: 01_subject1, 02_subject2, 03_subject3. Each subdirectory contains a source file with a language-dependent extension that compiles to an executable file whose name matches the source file name without the extension according to common practice.
I exclude the compiled files in the numeral-prefixed directories with the following .gitignore line:
[0-9][0-9]_*/[!\.]*
According to my understanding of the documentation, it shouldn't work. Having the trailing asterisk should fail because it should match any number of unspecified characters, including the '.' + extension. Omitting the trailing asterisk should fail (and does) because [!\.]
matches only a single non-period character. However, I added the trailing asterisk, as I would for a regular expression, and it works. By work, I mean that git notices changes to the source file, but not the existence or changes to the compiled files.