My issue is that I have a bunch of WordPress websites in my git repo, of which I want to selectively commit only the content of my themes
folders, while ignoring the rest of the redundant files found in WordPress.
I've used .gitignore files to ignore file types before, but can it be used the other way around- that is to ignore everything BUT a certain folder path?
root (git repo)
- / wordpress
- - / (WordPress Site 1)/wp-content/themes
- - / (WordPress Site 2)/wp-content/themes
- - / (WordPress Site 3)/wp-content/themes
Thanks-
UPDATE:
Based on the answers I did the following, but it's not working. Any ideas?
# Ignore everything:
*
# Except for wordpress themes:
!*/wp-content/themes/*
I've also tried the following variations:
!*/wp-content/themes*
!*wp-content/themes/*
!wp-content/themes/*
!/wordpress/*/wp-content/themes*
!wordpress/*/wp-content/themes*
None of these read my themes
folders.
I am in the same boat trying to manage a bunch of Wordpress sites under one repo. My directory structure looks like this:
I want to just track the items inside the
app/public
folder for each site. I tried the samples in this page as well as some of the suggestions here and ended up trying this:which worked but I would have to ignore the same path for each site which I was trying to avoid.
Then I just replaced the name of the site with
*
and that did the trick for me. So this is what I ended up using:This effectively ignored everything in the site's folder while capturing everything in the
app/public
folder for any site that I create in the root.Note that it will not ignore files in the root, just directories :)
Hope this helps.
You can try this:
Where: