Skip to main content

Cloning a Site to Your Local Development Environment and Using Git

Learn how to clone your Seravo site into a local Docker development environment with Git, pull the production database and plugins, and deploy code changes safely to production.

All new WordPress sites on Seravo come with Git version control pre-initialized in /data/wordpress/. Using Git keeps your code changes organized, enables safe local development, and provides a clear revision history for your entire development team.

Step 1: Clone the Site Code to Your Workstation

You can clone your production site's Git repository directly onto your local machine over SSH. To clone the repository, you need your site's SSH username, server hostname, and unique SSH port (available in the Seravo Plugin or by running srv system metadata).

Run the following commands on your local workstation:

git clone ssh://<ssh-user>@<site>.seravo.com:<ssh-port>/data/wordpress ~/Projects/<site> --origin production
cd ~/Projects/<site>

New Seravo sites are pre-built on Seravo's WordPress project template, so your local Docker environment works out of the box immediately after cloning.

Alternative Method: Pushing Your Own Project Template to a Blank Site

Warning: Do not do this if your site already has live content or custom code in production. Running git push --force overwrites the server's existing Git history and files.

If you are starting development from your own custom WordPress project template on a blank Seravo site, you can add the production server as a Git remote and push your codebase to the server:

git clone https://github.com/<organization>/<project>.git ~/Projects/<site>
cd ~/Projects/<site>
git remote add production ssh://<ssh-user>@<site>.seravo.com:<ssh-port>/data/wordpress
git push --force production master

Using Multiple Git Remotes

You can connect multiple Git remotes to your local project—for example, GitHub or GitLab for team collaboration alongside production for deployments:

git remote add origin [email protected]:organization/example-site.git
git remote add upstream https://github.com/Seravo/wordpress.git

Verify your configured remotes with git remote -v.

Step 2: Start the Local Environment and Pull Site Data

Once the project is cloned locally, start the Docker development environment from your project directory:

seravo-docker up

Open a shell session inside the local development container:

seravo-docker ssh

If you are working on an existing site, pull the production database, plugins, and themes into your local container using Seravo's built-in commands:

# Pull the production database and automatically update URLs to .local
wp-pull-production-db

# Pull production plugins
wp-pull-production-plugins

# Pull production themes
wp-pull-production-themes

Equivalent commands are also available for staging/shadow environments: wp-pull-staging-db, wp-pull-staging-plugins, and wp-pull-staging-themes.

Once the data has been imported, open the site in your browser at http://wordpress.local/ (or the custom .local domain configured in your project's config.yml).

Step 3: Deploy Changes to Production and Shut Down the Environment

Once you have made and tested your changes locally, commit them to Git and push them to production from your local workstation:

git add .
git commit -m "Descriptive message explaining the changes"
git push production master

Note that newer projects may use main as the primary branch name instead of master.

On the server side, .git/hooks/post-receive automatically runs configured build tasks (such as Composer and Gulp) if defined in the project.

When you finish working, stop the local Docker environment from your workstation:

seravo-docker down

Note: Do not delete /data/wordpress/.git on the server. Keeping the repository intact ensures that all changes made to the site remain tracked in version control history and that git push deployments continue working smoothly.

Common Issues and Troubleshooting

  • git push production fails with refusing to update checked out branch: By default, Git prevents pushing to a branch that is currently checked out in a non-bare repository. If you initialized the Git repository manually on the server, enable automatic working tree updates via SSH:

    cd /data/wordpress && git config receive.denyCurrentBranch updateInstead
  • Composer or build scripts do not run automatically after git push: If you initialized the Git repository yourself rather than using Seravo's project template, copy Seravo's post-receive hook into place on the server:

    cp /data/wordpress/scripts/git-hooks/post-receive /data/wordpress/.git/hooks/post-receive
  • wp-pull-production-db cannot connect to the production server: Verify that name (the SSH username), production.domain, and production.ssh_port are properly set in your local config.yml, and ensure your SSH key has been added to the server.

  • Media Library images do not appear in the local development environment: wp-pull-production-db transfers only the database, not media files stored in wp-content/uploads. You can copy specific files using rsync or configure a local nginx rule to proxy missing uploads directly from production.

See Also

Combining a Git-based workflow with a local Docker environment makes developing and deploying changes fast and reliable. If you need assistance cloning your site, configuring SSH access, or troubleshooting Git, our support team is happy to help at [email protected].

Did this answer your question?