A WordPress plugin that automatically synchronizes your WordPress site with a GitHub repository. Works with or without Git installed — uses GitHub's API as a fallback for managed/shared hosting.
- 🚀 No Git Required: Works on any hosting — uses GitHub API when git isn't installed
- 🔄 Auto-Sync: Automatically pushes when plugins/themes change
- ⚡ Background Sync: Handles large codebases (WooCommerce, etc.) without timeouts
- 📦 Auto-Create Repos: Creates private GitHub repositories automatically
- 🎛️ Admin Dashboard: Beautiful UI showing status, commits, and sync controls
- 🔐 Secure: All secrets stored in WordPress database, no env vars needed
- 📡 Webhook Support: Receives GitHub webhooks for notifications
| Mode | When Used | Capabilities |
|---|---|---|
| ⚡ API Mode | Git not installed | Push files to GitHub via API |
| 🔧 Git Mode | Git available | Full two-way sync (push + pull) |
The plugin automatically detects which mode to use. API Mode works great for managed WordPress hosting like WP Engine, Kinsta, Flywheel, etc.
- Download or clone this repository
- Upload the
wp-git-syncfolder to/wp-content/plugins/ - Activate the plugin through the 'Plugins' menu in WordPress
⚠️ Important: Your PAT must have the correct permissions or the plugin won't work!
- Go to GitHub Settings → Tokens (classic) ← This link pre-selects the required scope
- Give it a name like "WP Git Sync"
- Set expiration (or "No expiration" for convenience)
- Required scope: ✅
repo— Full control of private repositories - Click "Generate token"
- Copy the token immediately! (You won't see it again)
- Go to GitHub Settings → Fine-grained tokens
- Give it a name like "WP Git Sync"
- Set expiration
- Resource owner: Select your account
- Repository access: "All repositories" or select specific repos
- Permissions required:
Permission Access Level Why Needed Contents Read and Write Push/pull commits Metadata Read Access repo info Administration Read and Write Create new repos - Click "Generate token"
- Copy the token immediately!
- In WordPress admin, go to Git Sync → Settings
- Fill in:
- Personal Access Token: Your GitHub PAT
- GitHub Username: Your GitHub username
- Repository Name: Name for your repo (e.g.,
my-wordpress-site) - Author Name: Name for commits
- Author Email: Email for commits
- Click Save Settings
- Go to Git Sync → Dashboard
- You'll see the Setup Wizard
- Check the options:
- ✅ Create GitHub repository if it doesn't exist
- ✅ Make repository private (recommended)
- Click "Initialize Repository"
That's it! The plugin will create a private GitHub repo and push your files.
To get notified when someone pushes to GitHub:
- Go to Git Sync → Settings
- Copy your Webhook URL and Webhook Secret
- Go to your GitHub repo → Settings → Webhooks → Add webhook
- Configure:
- Payload URL: Your webhook URL
- Content type:
application/json - Secret: Your webhook secret
- Events: Select "Just the push event"
- Click Add webhook
When git isn't installed, the plugin uses GitHub's REST API:
How it works:
- Scans configured directories for files
- Creates blobs for each file via GitHub API
- Creates a tree with all files
- Creates a commit pointing to the tree
- Updates the branch reference
Pros:
- Works on any PHP hosting
- No server dependencies
- Direct API communication
Limitations:
- Push-only (can't pull from GitHub)
- Skips binary files (images, fonts, etc.)
- Skips files >10MB
When git is available, the plugin uses native commands:
How it works:
- Uses standard
git add,commit,push,pull - Full two-way synchronization
- Handles binary files normally
| Field | Description | Example |
|---|---|---|
| Personal Access Token | GitHub PAT with repo scope (see permissions below) |
ghp_xxxxxxxxxxxx |
| GitHub Username | Your GitHub username | your-username |
| Repository Name | Repo name (not full URL) | my-wordpress-site |
| Branch | Branch to sync with | main |
| Author Name | Commit author name | WordPress Server |
| Author Email | Commit author email | server@yoursite.com |
| Webhook Secret | For verifying GitHub webhooks | (auto-generated) |
| Repository Path | Path to scan for files | /var/www/html |
| Paths to Sync | Directories to include | wp-content/plugins/ |
| Auto-Sync | Sync on plugin/theme changes | Enabled/Disabled |
By default, the plugin syncs:
wp-content/plugins/
wp-content/themes/
wp-content/mu-plugins/
You can customize this in Settings → Paths to Sync. One path per line, relative to your WordPress root.
| Token Type | Required Permissions |
|---|---|
| Classic | repo scope |
| Fine-grained | Contents (RW), Metadata (R), Administration (RW) |
- Use a dedicated PAT - Create a token just for this plugin
- Set expiration - Consider rotating tokens periodically
- Use HTTPS - Always use HTTPS for your webhook URL
- Keep WordPress secure - The PAT is only as safe as your WordPress
- Monitor token usage - Check GitHub's token activity logs
If you see "API Mode" in the dashboard, that's normal! The plugin detected that git isn't installed and is using GitHub's API instead. Everything works, you just can't pull changes.
For sites with many files (WooCommerce stores, etc.), use Background Sync:
- Click "Background Sync (Large Sites)" instead of "Quick Sync"
- Files are processed in batches of 50
- A progress bar shows real-time status
- No timeout issues — takes as long as needed
- Smart SHA comparison skips unchanged files
Quick sync is designed for small changes. For large sites, use Background Sync. Subsequent syncs are faster due to SHA comparison (unchanged files are skipped).
- Check Settings → Paths to Sync includes your directories
- Binary files (images, fonts) are skipped in API mode
- Files over 10MB are skipped
- Check that directories exist and are readable
- Verify webhook URL is publicly accessible
- Check the secret matches in both places
- Note: In API mode, webhooks are received but can't trigger pulls
- Verify your PAT has
reposcope - Check username is correct
- Ensure repo name doesn't contain special characters
Plugin/Theme Change Detected
↓
Scan directories for files
↓
Create blob for each file (GitHub API)
↓
Create tree with all blobs
↓
Create commit
↓
Update branch reference
Plugin/Theme Change Detected
↓
git add -A
↓
git commit -m "Auto-sync"
↓
git push
↓
git pull (if webhook triggered)
The plugin syncs automatically on:
upgrader_process_complete- Plugin/theme installs & updatesactivated_plugin- Plugin activationdeactivated_plugin- Plugin deactivationswitch_theme- Theme changesdeleted_plugin- Plugin deletiondeleted_theme- Theme deletion
The plugin creates a .gitignore optimized for WordPress:
# Uploads (too large for git)
wp-content/uploads/
# Cache and backups
wp-content/cache/
wp-content/backup*/
wp-content/upgrade/
# Debug log
wp-content/debug.log
error_log
# Development files
node_modules/
# OS files
.DS_Store
Thumbs.db- ⚡ New: Background sync for large codebases
- ⚡ New: Batch processing (50 files at a time)
- ⚡ New: Real-time progress indicator with AJAX polling
- 🚀 Improved: Smart SHA comparison skips unchanged files
- 🚀 Improved: Much faster syncs for large sites
- 🔧 Fixed: Empty repository sync using Contents API
- 🔧 Fixed: Better error messages
- ✨ New: File scan preview in setup wizard
- ✨ New: Debug output for troubleshooting
- ✨ New: API Mode - works without git installed!
- ✨ New: Configurable paths to sync
- ✨ New: Skips binary files in API mode
- ✨ New: Mode indicator in dashboard
- 🔄 Changed: Auto-detects best sync method
- 📝 Improved: Better error messages
- Auto-create GitHub repositories via API
- One-click repository initialization wizard
- Auto-generate WordPress-optimized
.gitignore
- Initial release
GPL v2 or later - see LICENSE