Sync local and online WordPress installations - wordpress

I develop WordPress themes and I use git for version control. I use a git repo for each theme. The most of the time I am fixing and developing themes so I only need to push little changes to some theme. Because of that I only have the themes synchronized but I have differents plugins and content.
Now I want to completely sync my local and online WordPress installations to make any change in local, including create the content and make plugins and core updated.
I have found a plugin that allow to sync the database and media files. But what happens with plugins and all the wordpress core files?
I can make git repo of all the wordpress install, but I don't want to push all the installation because a little change in one theme. I need to track each theme apart.
Is there a way to make a repo of all WordPress, excluding themes, and maintain the repos I already have for the themes?

Finally, my approach has been to create a git repo of all the WordPress files excluding wp-content/plugins and wp-content/themes with the .gitignore.
So then, I have a repository for plugins, a repository for each of my themes and another repository for all the other files. This plus the WP Sync DB plugin allow me to have my local and production environments completely synchronized.
I hope this help someone!

Related

WordPress - How to track themes folder only from git repository

I have duplicated a WordPress site to my local machine, so that I can work and maintain it. Now assume that someone else has created a custom theme and created a git repository and pushed that custom theme (only the themes folder), so that I can integrate it into my WordPress intallation. How can I sync that theme folder to my WordPress installation?
Do I have to:
- git init
- git remote set-url origin git#github.com:USERNAME/REPOSITORY.git.
or am I wrong? how do I only track the themes folder?
Can someone help me out?

WP Core Update will leave wp-content alone?

Hi I have a wordpress website and want to update via wp-cli.
Will the command wp core update leave the wp-content folder alone?
The upgrade process will affect all files and folders included in the main WordPress installation(Mainly it's wp-admin and wp-includes). This includes all the core files used to run WordPress. If you have made any modifications to those files, your changes will be lost.
Simply, you can change only wp-content files. And wp-content will not be affected by core update.
But, I suggest to take backup before any update.
[user#server]$ wp core update will not update the wp-content folder ideally.
You should be careful with WP CLI as it can upgrade to a major version of wordpress instead of a minor one. This might lead to plugin incompatibility.
Please use the following commands to check the version and upgrade to a minor version if necessary.
[user#server]$ wp core version
[user#server]$ wp core update --minor
Also it is a very good idea to take a complete backup before updating your wordpress installation.
You can use a free plugin like Duplicator which will give you a nice backup for your installation.
Happy updating!!

Where to save plugins for openshift wordpress install

I would like to upload a custom installation of openshift. I have installed wordpress and cloned it via git. Now I would like to add manually some plugins and push it back to openshift. Where do I have to put in my extracted plugins/themes?
I appreciate your answers!
Short answer: store your plugins and themes in .openshift.
Longer answer:
Every Openshift account has what can be thought of as a username - a long number like this:
53f1a90f500446c42053423083
Each directory structure features this number so yours:
/var/lib/openshift/53f1a90f500446c42053423083/app-root/runtime/repo/.openshift
will be different to mine:
/var/lib/openshift/12345678901234567890123456/app-root/runtime/repo/.openshift
The number gets incorporated into environment variables so that scripts will work on yours and mine equally. One of these is OPENSHIFT_REPO_DIR. On your install it will point to:
/var/lib/openshift/53f1a90f500446c42053423083/app-root/runtime/repo
on mine:
/var/lib/openshift/12345678901234567890123456/app-root/runtime/repo
Another is OPENSHIFT_DATA_DIR.
When you push changes from your local directory via git, the deploy script is run and it assembles all the wp files it needs into a directory it names:
OPENSHIFT_DATA_DIR/current
Openshift moves the 'original' wp plugins and themes folders that are created during a wp install into the OPENSHIFT_DATA_DIR/current/wp-content. It looks in OPENSHIFT_REPO_DIR/.openshift for your code and copies in any plugins and themes folders it finds there.
Net effect is to assemble the plugins and themes directories by adding yours to those that came with wp. So, your fully-assembled OPENSHIFT_DATA_DIR/current will have these in it:
OPENSHIFT_DATA_DIR/current/wp-content
/themes
/plugins
/uploads
So, anything you put in .openshift will be copied to the right place, but not altered.https://github.com/openshift/wordpress-example

WordPress updates overwrite .svn folder

We're using Subversion to keep track of the changes our web team makes to our Wordpress site. We do nothing more than modify and update our custom theme, but we have difficulty updating the Wordpress core and plugins.
Right now, I have my checked out copy working on a local WordPress install. However, when I run the automatic WordPress updates on this local copy, the updates overwrite the .svn folders in the respective subfolders, resulting in a "Directory .svn containing working copy admin area is missing" error when I try to commit the update.
How can I do these updates automatically without overwriting the .svn folder? As of now I am resorting to copying the files in manually.
If you're just maintaining your theme, you should not have the whole wordpess install under svn but just the theme. I also think in your case it doesn't make sense to actually use a working copy of your repository in the actual live site. In your case I'd keep a working copy of your theme somewhere on your server and then rsync on demand to your theme folder. This way you can update wordpress and your plugins automatically and without problems.

Why do a few resources suggest excluding the WordPress install from a Git repository?

While switching a WordPress site onto Git I looked for a .gitignore template. But I stumbled upon a reoccurring theme.
Fact: you don't want WordPress core files, or your server-specific configuration files etc., in your project's repository. You just don't. – Joe Bartlett
And the recommended GitHub .gitignore for WordPress excludes all wp-*.php files. Wordpress.gitignore.
Why is this recommended? Surely I’d want as many core files to be included as possible, otherwise I have to install WordPress on every server I deploy to.
If context helps, I’m deploying it to a load balanced network with two application servers and two database servers.
The only thing I keep in a repository is the theme, never any core WordPress files. In the readmes I keep track of what versions it works with.
It's probably not recommended to help discourage modifying the core files.
Another idea is to keep WordPress as a clean git repo with your themes as submodules, that way you can upgrade/rollback WordPress separate from your themes. This is also how I maintain sites that use frameworks.
This is recommended in order to keep only YOUR files into your repository. Then using a script (or something else) you can retrieve the WP sources.

Resources