This guide explains how to deploy your local changes to Seravo’s production environment using Git.
Requirements
SSH configuration: Ensure your SSH keys are set up.
Local Git checkout: You need a local copy of your site.
Project directory: Navigate to your project folder locally.
Deploying Changes
In this example, we have production set as git remote:
# We are using custom alias 'your-site' in ~/.ssh/config
git remote -v
production your-site:/data/wordpress/.git (fetch)
production your-site:/data/wordpress/.git (push)
# This is the output if project was cloned without ssh alias
git remote -v
production ssh://[email protected]:12345/data/wordpress (fetch)
production ssh://[email protected]:12345/data/wordpress (push)
To deploy your changes, run:
git push production master
What happens during deployment?
By default, Git only transfers the changed files. To ensure your site functions correctly after an update, we recommend using a post-receive hook to automate essential tasks.
Recommended post-deployment tasks:
Flushing Caches: Clear WordPress object cache and Nginx page cache to make changes visible immediately.
Build Tasks: Run tools like Gulp or SASS if your project requires compilation.
Dependency Management: Run
composer installif you manage plugins or themes via Composer.
Using Git Hooks
You can create a script at /data/wordpress/.git/hooks/post-receive on the server. This script will execute every time you perform a git push.
Example post-receive script:
#!/bin/bash
echo "Seravo: Running post-receive tasks..."
# Flush caches
wp cache flush --path=/data/wordpress/htdocs wp-purge-cache
# Run Gulp if applicable if [ -f "/data/wordpress/htdocs/gulpfile.js" ]; then
cd /data/wordpress/htdocs && gulp build
fi
Note: Make the script executable by running: chmod +x /data/wordpress/.git/hooks/post-receive
Important: Database and Media Files
By default, Git deployment does not include the database or the contents of the uploads folder.
Recommendation: We strongly advise against including the database or media files in your Git repository. Doing so makes the repository unnecessarily heavy and difficult to manage.
Data Migration: If you need to deploy database contents or media files, you should use separate tools (such as
wp-clior SSH-based transfers).Security: While it is technically possible to include these files in Git, it is risky. Always ensure that your deployment method is safe and does not accidentally overwrite dynamic data created in production, such as new posts or customer orders.
Tutorial: Your First Deployment
Configure Remote: Add the Seravo production server as a Git remote in your local project.
git remote add production ssh://[email protected]:12345/data/wordpress
Push to Production:
git push production master
