Let's say I have ignored a directory, but I want to unignore specific subdirectories therein. So I have the setup:
/uploads/
/uploads/rubbish/
/uploads/rubbish/stuff/KEEP_ME/
/uploads/foo/
/uploads/foo/bar/lose/
And I want to ignore everything but the KEEP_ME
directory. I would hope the ignore would look something like:
/uploads/*
!/uploads/rubbish/stuff/KEEP_ME/
But that's not working, and neither are several permutations on the same theme.
One that does work is
/uploads/**/**/**/
!/uploads/rubbish/stuff/KEEP_ME/
But that feels a little restrictive and verbose?
Was trying to figure out how to include a specific folder when excluding all folders with the generic exclusion
if you add the
/*
to the end of your generic exclude you continue to exclude all build files**/build/*
Then you add another line to correct for the path that you want to be included to look like
leaving us a gitignore that reads
According to pattern format section of the gitignore documentation:
Therefore the previously-excluded parent directory
/uploads/rubbish/stuff/keep/
pattern must be exclusively negated before negating its content:To include subdirectories inside
/uploads/rubbish/stuff/keep/
add the third line:Even if you add something to
.gitignore
, you can force git to add it to the indexHowever, "KEEP_ME" seems to be a directory and git usually doesnt like empty folder, so you should can add a "placeholder"-holder file instead, if the folder is empty