Ignore containing folder, but not a folder within

I’m cleaning up my development workflow and I was wondering if it is at all possible for Git to ignore a containing folder, but allow folders within?

Allow me to clarify.

Read More

I’m currently working on my website and I’m theming my new WordPress blog – Obviously I have a local installation of WordPress and a remote installation. I want to be able to ignore the main folders and only allow the themes folder. The structure is as follows.

  • Blog
    • wp-content
    • wp-includes
      • themes
      • modules
    • […]

I want to ignore absolutely everything except the themes and modules folder – how would I do this in my .gitignore?

Related posts

Leave a Reply

1 comment

  1. How about this:

    # Ignore everything in the top-most directory
    /*
    
    # Except the wp-includes directory
    !wp-includes/
    
    # Exclude everything in the wp-includes directory
    wp-includes/*
    
    # Except the folders themes and modules
    !wp-includes/themes/
    !wp-includes/modules/