Ignore containing folder, but not a folder within - wordpress

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?

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/

Related

git allow one directory while exclude rest folder in .gitignore fle

I have a Wordpress website in which I have code as shown below:
wp-content/uploads/
which exclude uploads wp-content/uploads/ from git commit. But now I reached to the case where I have to include a subfolder wp-content/uploads/MY_CUSTOM_PDF
How should I only allow MY_CUSTOM_PDF to be included in git commit while ignore the rest as it was earlier.
Solution already exist.!!
.gitignore exclude folder but include specific subfolder
if sometimes git command-line ignore not work due to already uploaded folder so use smartgit ignore unwanted error

Exclude auto-generated image sizes in WordPress uploads folder with gitignore

I have a directory structure similar to bedrock. So WordPress in its own subdirectory wp/ and the stuff that normally goes into wp-content is in app/. I want to exclude all directories in app/ BUT uploads/.
But inside uploads/ itself I want to exclude every image that was automatically generated by WordPress. So every file that follows the pattern $original_image_name-$widthx$height.$ext.
I tried the different solutions from all the already asked questions there are and my current (still not working) .gitignore looks like this now:
.gitignore
# WordPress
public/wp/
public/app/*
!public/app/uploads
public/app/uploads/*-*x*.* # auto-generated sizes
When checking git status public/app/uploads/ it still shows the auto-generated files as Untracked files along with the other images.
The error actually just was that I added the # comment in the same line as the pattern..
So what I got now is
.gitignore
public/wp/
public/app/*
!public/app/uploads/
public/app/uploads/*-*x*.*

Git - Track a folder from a separate repository and have a separate repository set up inside of it

I have the following folder structure running on an NGINX server.
-- Laravel installation
-- Magento installation [DOCUMENT ROOT]
-- Laravel's public folder renamed to a different name
-- WordPress installation
The website structure goes something like:
www.example.com = Magento
www.example.com/subsite = Laravel [This is its 'public' folder.
Rest of the folders are placed in a separate folder]
www.example.com/subsite/blogsite = WordPress [Running inside of Laravel]
I had to do the Laravel folder separation because I wanted to make it work as a subdirectory but somehow couldn't figure out how to do it. So I instead followed the Method #1 in this post.
The challenge now is to manage these 3 repositories separately.
I have two major concerns:
How do I track the stranded Laravel public folder which is now inside the Magento repository?
How can I manage the WordPress installation as another separate repository?
1. How do I track the stranded Laravel public folder which is now inside the Magento repository?
As per this answer, you can add external directories to your working tree with this git command:
git --work-tree=/ add /home/some/directory
2. How can I manage the WordPress installation as another separate repository?
You can use .gitignore to ignore the subfolder in the Magento subfolder.
In the Magento root, create a file named .gitignore
In this file, create a list of folders/files you want to ignore, in your case you want to ignore the Wordpress folder within the Laravel directory (assuming it's under public/wordpress.
/public/wordpress/
/public/wordpress/*
Do a git commit: git commit -am 'Ignore the Wordpress folder'
Now you can just create a seperate git tracking instance on the Wordpress folder.

Git Ignore sub directory for WordPress theme

I am trying to setup GitIgnore to work with Git Tower (www.git-tower.com) and WordPress.
I want to have the repository in the root directory with the option to include just specific themes and plugins.
I will start with including just one theme sub directory.
Tower is not showing me the single theme directory. Instead it shows all of the wp-content folder. I expect this to be ignored as I have specified this in the ignore file.
So.. root: /
Directory to include: /wp-content/themes/raison-winetrust/
I tried the following:
/*
!.gitignore
!/wp-content/
/wp-content/*
!/wp-content/themes
/wp-content/themes/*
!/wp-content/themes/raison-winetrust/
Screenshot: https://www.dropbox.com/s/9lajg1h89n2jwkr/Screenshot%202015-01-23%2013.53.48.png?dl=0
Any advice appreciated.
Thanks
If you are only tracking that theme (not any of the other wordpress gubbins) why not initialise the git repo in the theme folder?
The other option is that you just do a git add of that folder and only add that folder when there are changes.

Trying to set up a .gitignore file for Wordpress Installation

I am trying to set up git for a Wordpress installation and am attempting to write a .gitignore file that will exclude EVERYTHING BUT my child theme folder. Here is what I have so far:
# Ignore everything in the root except the "wp-content" directory.
/*
!.gitignore
!wp-content/
# Ignore everything in the "wp-content" directory, except the "plugins"
# and "themes" directories.
wp-content/*
!wp-content/plugins/
!wp-content/themes/
# Ignore everything in the "plugins" directory, except the plugins you
# specify (see the commented-out examples for hints on how to do this.)
wp-content/plugins/*
# !wp-content/plugins/my-single-file-plugin.php
# !wp-content/plugins/my-directory-plugin/
# Ignore everything in the "themes" directory, except the themes you
# specify (see the commented-out example for a hint on how to do this.)
wp-content/themes/*
!wp-content/themes/my-theme/
This is only showing the child theme folder itself, not the contents. I feel like this can't be right based on the documentation I've seen so far (https://gist.github.com/jdbartlett/444295). Any suggestions?
Simply create a child theme repo or git submodule.

Resources