Ignore a directory except specific files in a subdirectory in Git
So, I’ve tried this with several approaches, but only this one works:
/* !/dev/ /dev/* !/dev/host/ /dev/host/* !/dev/host/mail/ /dev/host/mail/* !/dev/host/mail/htdocs/ /dev/host/mail/htdocs/* !/dev/host/mail/htdocs/install/
What I want is to ignore all files, except inside /dev/host/mail/htdocs/install/.
So all other files should be ignored entirely, except the ones inside the mentioned sub-folder.
- Git checkout just a subdirectory
- gitweb snapshot of sub-directory
- git-archive a subdirectory --
- GitIgnore ! File in Subdirectories
- Binding a subdomain to a directory without apache (available through ssh)
- SVN move single directory into other repository (with history)
I’ve tried this, but it doesn’t work:
Any idea how to shrink down the mess above? Do I really need as many lines as above; two lines for every directory level?
Am I missing something? Thanks a lot!
One Solution collect form web for “Ignore a directory except specific files in a subdirectory in Git”
Allowing everything under install after ignoring everything else (
*) has the form
* !/dev !/dev/host !/dev/host/mail !/dev/host/mail/htdocs !/dev/host/mail/htdocs/install !/dev/host/mail/htdocs/install/*
But this also allows stray files at higher levels of the tree. That means adding the additional ignore rules from your question.
The short answer is what you have is necessary. It is an odd repository structure, so git does not optimize for it.