I have looked through all previous stackoverflow questions related to this, but found none of the answers there to match what I want to do.
I am developing a component and a template for a content management system. All of my component files are in a subdirectory called 'components/com_rhgallery/', all of my template files are in a subdirectory called 'templates/rhgallery/'
I would like to have a single repository at the root and a single '.gitignore' file. I would prefer not to use git's submodule features as these are overkill for what I need.
Ideally I'd like to create a gitignore file that ignores everything in the project apart from the contents of the directories 'components/com_rhgallery' and 'templates/rhgallery/'
Simplistic solutions such as the following don't work because of the way that git works:
* !components/com_rhgallery/ !templates/rhgallery/
Linus (himself!) in one posting had suggested force adding files or directories, but this is only appropriate when there are a small number of files to be added and when the directory structure is failry static.
So, my question is, how would you create a single gitignore file to accomplish this relatively simple task of ensuring that only those files in these two directories are tracked?
.gitignore : * !/components/com_rhgallery/* !/templates/rhgallery/* components/com_rhgallery/.gitignore : !* templates/rhgallery/.gitignore : !*
might solve your problem.
using this approach seems to work without the addiitional * matche - user1104799 2012-04-04 05:17