Ignore containing folder, but not a folder within

Luke Berry

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?

mart1n

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/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related