简体   繁体   中英

Gitignore Syntax to Ignore Dynamic Directories

I have a theme directory in my app that contains directories for sections of the app, then beneath theme name directories, the beneath that, a views directory, and possibly controller, language and model directories like so:

theme
   admin
      themename
         view
   front
      themename
         view
         controller(optional)
         model(optional)
         language(optional)

All views should be included in the repo as they are part of the core installation, but controllers, models, and language files would be added by the developer to override the core files of the same name and structure. These files should not be included in the repo as they aren't core based.

I first tried:

/app/theme/*/*/*
!/app/theme/*/*/view

This didn't work so I researched and it seems that the ** is supposed to represent a dynamic directory so I then tried:

/app/theme/**/**/*
!/app/theme/**/**/view

But these files are still included in the repo.

Is there some trick I'm missing to get these to show as ignored?

/app/theme/*/*/*
!/app/theme/*/*/view

in .gitignore is working for me.

You have to remove the files from your git repository, if you have already commited them. You have to do something like that:

git rm app/theme/*/*/{controller,language,model} --cached

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM