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.

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?

Solutions

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/
Tags: Wordpress / Git / Module

Similar questions

How to ignore folder in site root while accessing a URL
I have a folder in my site's public_html directory called /connect. The folder is causing the page sitename.com/connect to access a parent index page instead of the Wordpress page set up. Deleting this folder solves the problem, but this folder keeps getting added daily by my autoSSL program. It was due to a connect.sitename.com subdomain being set...
How to set CodeIgniter to ignore Wordpress folder?
I built a website with CodeIgniter last year www.example.com, and client wanted Wordpress Blog last week. I built the blog and uploaded to www.example.com/blog Now when I click any link on wordpress it gives error as below :/ http://www.example.com/blog/category/one-last-category/ An Error Was Encountered Unable to load your default controller. Ple...
How to ignore a wordpress permalink and use the folder path instead
I have a wordpress site but want to have another microsite within one of the folders. www.example.com = main site www.example.com/shop = new site However on the main site I have pretty permalinks turned on, how do I make an exception for just "shop". Below isnt working.
How to ignore sub-folder requests and continue processing URI mapping using mod_rewrite?
An default example file for a default Wordpress deployment is: I have a special case scenario though where I have a subfolder as such in my root web directory that I need ignored: I basically need: to be ignored, but I do need: to be directly accessible and served. The problem is that /folderA/folderB currently maps to a URI in my Wordpress install...
How do you tell Wordpress to ignore a folder, in favor of a permalink?
I have a client who had a non-WordPress site, with a WordPress blog located in a subfolder /blog/. We launched them a new WordPress site in the root. Unfortunately, all the images in their blog posts are still pointing at /blog/wp-content/uploads/. I want to just add all these images to a subfolder on the file tree at /blog/wp-content/uploads, so i...
How can I ignore folder name in wordpress?
I have a local wordpress website on IP "192.168.0.115". There is a page in it called "Invoice" ("192.168.0.115/invoice"). I have about 800 PDF (invoice) files. I would like their URL to be "192.168.0.115/invoice/invoice001.pdf", "...002.pdf" and so on. What I did: I made a folder called "invoice" in the htdocs folder next to "wp-admin", "wp-content...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.