Search code examples
gitgitignore

gitignore in subdirectory is not allowing a whitelisted entry


git is located in a subdirectory("web" folder) along with .gitignore. The following gitignore code is giving me some issues.

**/app/themes/  #Should ignore all folders in the themes subdirectory
!*/app/themes/folder1  #allow one single folder and it's content to be versioned

I've tried a few combinations like /app/themes, and */app/themes -- any help would be wonderful! Thanks in advance!!


Solution

  • I think you want to do

    app/themes/**
    !app/themes/folder1 
    

    This will match all files in path url/app/themes. What you have in your first line is: match all folders named themes which are a subfolder of app regardless of where app is. You don't wont to just have

    app/themes
    

    because that would ignore the entire folder, and not allow for the negation in the line after.