WordPress in Git: moving a site into a repository

Published · 2 min read

As long as a WordPress site lives only on the server, every change is a live edit with no history and no calm way back. Moving it into a Git repository fixes that and opens the way to automatic publishing and working through an AI agent. There are two paths, and the choice depends on what the site does.

Path 1. Keep WordPress, put the code in Git

This suits sites that need an admin panel for editors, a WooCommerce shop, customer accounts or plugins that cannot be replaced without WordPress.

What goes into the repository:

  • your theme or child theme;
  • your own plugins and mu-plugins;
  • the list of third-party plugins with versions (via Composer or a plain list);
  • configuration without secrets, and notes for developers.

What stays out:

  • WordPress core — it is installed separately;
  • the uploads folder with media — it needs backups, not Git;
  • wp-config.php with passwords — secrets stay on the server or in environment variables;
  • the database — content still lives there.

Publishing: code changes from the repository are deployed automatically, through the host's Git deployment or GitHub Actions (rsync/SSH). WP-CLI handles database tasks: search and replace of URLs, plugin updates, cache flushes.

Path 2. Export the content into a static site

This suits company sites, blogs and multilingual sites whose content does not change every minute. That is how this site moved.

  1. Posts and pages are pulled through the WordPress REST API and saved as Markdown with metadata: language, URL, SEO title and description.
  2. Images are downloaded into the repository.
  3. A site generator builds ready HTML pages from these files.
  4. Old URLs are kept one to one or get 301 redirects.

The benefits: no PHP or database, nothing to patch or hack, cheaper hosting, and all content is plain files that are easy to edit by hand or through an AI agent.

What to check before moving

  • The list of every URL in the sitemap — after the move each must open or redirect.
  • Forms, search and comments — a static site needs replacements for them.
  • Analytics, Search Console and tracking.
  • Multilingual setup: translation links and hreflang.

What comes next

Once the site is in a repository, the next step is automatic deployment to your host from GitHub and working through an AI agent. If you need help with the move, see agentic website management.

Need help with this?

New service

Agentic website management

Local machine → repository → server: you ask, an AI agent changes the site, every change is reviewed, saved and deployed automatically. I set it up and teach your team.

How it works →

More articles

· 2 min read

Automatic deployment to Hostinger from GitHub

How to publish a site to Hostinger automatically from a GitHub repository: Git deployment in hPanel, a webhook, a GitHub Actions build and keeping secrets safe.

Contact

Let's talk about your project

An AI agent, an automation, a website improvement or a full rebuild — describe the task in a few lines and I will reply within one business day.

Tallinn, Estonia · working remotely across Europe