git and local wordpress: how to handle wordpress updates?

I see that Git and WordPress are often discussed here, but I didn’t find any answer to my specific question, so I’ll open a new one.

Just to get a little familiar with git, I want to use it for my personal wordpress blog. My setup:

  • local WordPress installation
  • remote repo (bitbucket)
  • automatic deployment everytime I push to bitbucket via FTP to my webhost (no chance installing git there, I use buddy)

So far its working fine, I can modify my stuff, write plugins etc and push it to the host. I wrote a small script to update my local dbs from time to time to have new comments etc. on my local installation, that works too.

But how do I handle plugin/wordpress core updates? Applying them directly to the production environment on my host would undermine the whole idea if git (i think), so I disabled automatic updates. But how to proceed?

  • Installing updates locally, committing and pushing them to the repo+host? What about db changes then? Do wordpress/plugin updates change something in the db? I guess they do?

  • Installing them on my host, then downloading everything via FTP, commit and push again (sounds redundant, and not really what I like to do)?

How do you handle this problem? Or is my setup completely wrong in some way?

Solutions Collecting From Web of "git and local wordpress: how to handle wordpress updates?"

I would formulate your requirements like this:

  • repository should capture complete and precise state of site
  • updates should be tested locally and pushed to production
  • database update events should run in production reliably

Sticking with Git alone that would indeed mean that you need to install updates locally and commit them into repository.

As for database updates WordPress core itself versions database structure and checks for it on boot. If database is outdated upon visiting site’s admin you will be prompted to perform update. I think more busy sites often choose to override that behavior in favor of running it behind the scenes on demand instead.

This mostly leaves auditing specific plugins you use to check if they use custom database tables and such. It’s not that common among WP extensions, most of them get by with native WP data structures and APIs.

As for possible improvement I would recommend to look into Composer and handling WP core as dependency. That would remove the need to keep copy of whole WP core in your repo.