Is Git/GitHub a good WordPress deployment solution?

Posted by Ramesh Singh | Updated on

If you are going to start your new WordPress project & want to maintain code versioning system and you have the following question in your mind:

1. Is Git/GitHub a good WordPress deployment solution?
2. How to Use GitHub for WordPress Development?
3. How to host WordPress website on Github

Answer: I am using Github for my website and I find it works really well. Based on my experiences following are few suggestions:

  • Add your uploads directory (wp-content/uploads) directory to your .gitignore file.
  • Run a web server and database server on your development system so you can test changes locally before pushing them to production.
  • Keep your database connection settings consistent beween dev and prod, or add wp-config.php to your .gitignore file to prevent your development wordpress settings overwriting your production ones.
  • Avoid updating plugins on your production system using the admin interface of WordPress – as at best, your git copy will overwrite any plugins you update as soon as you push/checkout, at worst you’ll get conflicts. Do your updates using the the admin interface on your development system, commit, push and checkout in production.
  • Consider adding a git post-receive hook to checkout your updates automatically into the directory you use to publish wordpress via your web server (e.g. /var/www). This allows you to only check out the files themselves, avoiding any git metadata finding it’s way into your web server’s document root, and also means you can add any permission changes into the post-receive hook so your permissions stay consistent every time. An example is included below:

Thanks to James Hebden to share this answer.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers