How do I ignore all files except one or two directories?

I've looked at all the previous stack questions related to this, but couldn't find any of the answers there to match what I want to do.

I am developing a component and template for a content management system. All my component files are in a subdirectory called "components / com_rhgallery /", all my template files are in a subdirectory called "templates / rhgallery /"

I would like to have one repository in the root and one .gitignore file. I would rather not use git submodule functions as they are too small for what I need.

Ideally, I would like to create a gitignore file that ignores everything in the project except the contents of the / com _rhgallery 'and' templates / rhgallery / 'directories components

Simplified solutions like the following don't work because of the way git works:

*
!components/com_rhgallery/
!templates/rhgallery/

      

Linus (himself!) Suggested in one post to force the addition of files or directories, but this is only suitable when there are few files to add and when the directory structure is static with an error.

So my question is, how would you create a single gitignore file to accomplish this relatively simple task of keeping track of only those files in those two directories?

+3


source to share


1 answer


I believe

.gitignore :
*
!/components/com_rhgallery/*
!/templates/rhgallery/*

components/com_rhgallery/.gitignore :
!*
templates/rhgallery/.gitignore :
!*

      



might solve your problem.

+2


source







All Articles