Skip to main content
  1. All Posts/


Tools Open Source Sync WordPress

GitHub Sync

A WordPress plugin to synchronize a directory with a repository hosted on GitHub.


  • PHP exec() function
  • Git
  • Shell access to server


1: Setup the git repository on your server.

You can use this plugin to keep a directory synchronized. This directory
can be a theme, a plugin, the whole wp-content, or a directory outside
of your WordPress installation.
Your PHP user (Apache with mod_php_, php-fpm, etc.) should have the
permission to write in the directory. Use the “Git Read-Only” URL if you
want to clone with a system user and pull with your PHP user easily.
If the repository is private, or if you need to commit / push from this
directory, you will need to generate an SSH key for your PHP user, and
to configure git. Please refer to the git / GitHub documentation.

$ cd /path/to/wp-content/themes
$ git clone ./my_theme

2: Install the plugin

Follow the classic WordPress procedure to install and activate the
Define the following settings in your wp-config.php:


// The repository directory (required)
define('GITHUB_SYNC_DIR', __DIR__. '/wp-content/themes/my_theme');

// The repository GitHub ID (required)
define('GITHUB_SYNC_REPO_ID', 'my_name/my_theme');

// GitHub IP addresses (optional, default below)
define('GITHUB_SYNC_IPS', ',,');

// The branch to keep synchronized (optional, default: "master")
define('GITHUB_SYNC_BRANCH', 'master');

// The git remote (optional, default: "origin")
define('GITHUB_SYNC_REMOTE', 'origin');

// Enable logging to debug the plugin (optional, default: NULL)

3: Add a GitHub WebHook URL

On your GitHub repository, add a WebHook URL (GitHub instructions)
with your WordPress base URL, followed by /github-sync/, e.g.: