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:
.gitignore
file..gitignore
file to prevent your development wordpress settings overwriting your production ones.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:1 2 3 4 5 6 7 8 9 10 11 12 | #!/bin/sh unset GIT_INDEX_FILE # the directory your web server serves wordpress from export GIT_WORK_TREE=/var/www/example.com/ # the local directory where your remote git repository sites export GIT_DIR=/home/git/repos/example.com.git/ # below user is for debain - you want the user and group your webserver uses sudo git checkout -f sudo chown -R www-data:www-data $GIT_WORK_TREE sudo chmod -R 755 $GIT_WORK_TREE sudo chmod 600 $GIT_WORK_TREE/wp-config.php sudo chmod -R 775 $GIT_WORK_TREE/wp-content |
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.