.gitignore Meson subprojects
Meson projects using Meson subprojects have a project directory structure like:
meson.build
main.c
subprojects/
lapack/
lapack.wrap
where “subprojects/lapack/” is automatically created as a Meson subproject from the metadata in “subprojects/lapack.wrap”. It’s desirable to ignore the subprojects code directories in Git.
For Meson subprojects, using the negate .gitignore syntax Git will ignore subdirectories but track the subprojects/*.wrap files, by including in the project top-level .gitignore:
/subprojects/*
!/subprojects/*.wrap
This technique can be applied to similar non-Meson scenarios.
NOTE: The .gitignore syntax has a precise meaning.
For example, /subprojects/*
means to ignore the directory contents of top-level directory “subprojects”, but not the directory itself.
This is important for the next stanza !/subprojects/*.wrap
, which means to not ignore files with .wrap suffix in top-level directory “subprojects”.
Thanks to @lunasorcery for pointing out the correct .gitignore syntax.