Should I Upload Entire WordPress Site at GitHub? Pros & Cons!
Do not upload your whole WordPress site to GitHub. Commit your own code, keep wp-config.php, uploads and the database out. Tested .gitignore inside.

No, you should not upload your entire WordPress site to GitHub. Put the code you wrote yourself (your theme, custom plugins, mu-plugins and build files) in a private repository, and keep WordPress core, the uploads folder, wp-config.php and the database out of it. GitHub is excellent for tracking and deploying code, but it is not a backup, it is a poor home for media files, and a committed wp-config.php puts your database password and security keys in every copy of the repository forever.
We rebuilt this guide on 18 November 2026 and tested the advice on a real WordPress 7.1.4 install instead of repeating the usual list. With GitHub’s own WordPress .gitignore template, Git tracked 106 of the site’s 3,842 files, about 2.2 MB instead of more than 100 MB. The same test also showed two things that template misses, which we cover below with a fixed version.
Should I upload my entire WordPress site to GitHub?
Upload the parts that are code you own and change. Leave out the parts that WordPress, plugin authors or your visitors create. This table is the short version most developers settle on.
Part of the site | Put it in GitHub? | Why |
|---|---|---|
Your custom theme or child theme | Yes | It is your code and changes often |
Your custom plugins and mu-plugins | Yes | Same reason, and you want history and review |
Build files ( | Yes | They describe how to rebuild the site |
A sample config ( | Yes | Shows which settings exist, with no real values |
WordPress core ( | No | It is the same for everyone and updates on its own schedule |
Third-party plugins and themes | Usually no | Install them from WordPress.org or Composer at a pinned version |
| Never | They hold database passwords and security keys |
The uploads folder | No | Large binary files bloat the repository and are not code |
The database or | Never | Personal data, password hashes, and it changes every minute |
If you want a full copy of everything for disaster recovery, that is a backup job, not a GitHub job. The next section explains why the two are different.
Is GitHub a good backup for a WordPress site?
No. A WordPress site is two things: files and a database. Posts, pages, users, orders, settings and comments all live in the database, and GitHub stores files. A repository full of PHP files without the database cannot bring your site back. The uploads folder is also missing from a well-run repository, so your images would be gone too.
Git also keeps every version forever, which is the opposite of what you want for a database dump. If you commit a .sql file once and delete it later, it is still in the history, along with every customer email address and password hash it contained. Use a real backup tool or your host’s snapshots for the database and uploads, keep them off the web root, and use GitHub for code history. Our guide to updating WordPress safely covers the backup-before-update habit that belongs alongside a Git workflow.
What happens if wp-config.php ends up on GitHub?
Assume every secret in it is compromised, even in a private repository. wp-config.php holds your database name, user and password, and the authentication keys and salts that sign login cookies. Anyone holding the salts can forge a logged-in cookie, and anyone holding the database password can read or change your data if they can reach the database server.
This is not a rare slip. GitGuardian’s State of Secrets Sprawl 2026 report, published on 17 March 2026, counted about 28.65 million new hardcoded secrets added to public GitHub commits during 2025, a 34% rise on the year before.
Does GitHub stop me pushing secrets?
Sometimes. GitHub’s push protection documentation says push protection is on by default for user accounts, but only blocks pushes to public repositories on GitHub.com. For repositories it is off by default, and an admin has to turn it on. It also recognises known token formats, so a plain database password in wp-config.php may not look like a secret to it at all. Do not rely on it as your safety net.
How do I clean up a leaked wp-config.php?
Follow GitHub’s own order in removing sensitive data from a repository: rotate first, rewrite history second.
- Change the database password on the server and update
wp-config.phpon the live site. - Replace the keys and salts with a fresh set. Every user is logged out, which is what you want.
- Rotate anything else in the file: SMTP keys, API keys, licence keys.
- Add the file to
.gitignoreand remove it from tracking withgit rm --cached wp-config.php. - Rewrite history only if you need to. GitHub recommends
git-filter-repowith--sensitive-data-removal(version 2.47 or later) and warns that forks, clones and cached views can still hold the old commits.
Is a private GitHub repository safe enough for WordPress?
Safe enough for code, not for secrets. GitHub’s Free plan includes unlimited public and private repositories (pricing page, checked on 18 November 2026), so there is no cost reason to make a site repository public. But “private” only means private to everyone with access: every collaborator, every laptop that cloned it, every CI service and every personal access token with repository scope. Treat a private repository as a place where secrets will eventually leak, and keep them in environment variables or your host’s secret store instead.
Our wp-config.php constants guide shows which settings belong in that file. A common pattern is a committed wp-config.php that reads every sensitive value from the environment, with the values themselves stored on the server and never in Git.
How big can a WordPress repository on GitHub be?
GitHub’s large files documentation (checked on 18 November 2026) sets these limits:
Limit | Value |
|---|---|
Warning when you add a file | Over 50 MiB |
Push blocked | Any file over 100 MiB |
Upload through the browser | Up to 25 MiB per file |
Recommended repository size | Ideally under 1 GB, strongly recommended under 5 GB |
Files above 100 MiB | Need Git Large File Storage (Git LFS) |
Here is how those limits compare with a real site. On our test install, wp-includes alone was 88 MB and wp-admin 10 MB before a single upload. A working site with a few years of images, plugin caches and backup archives in wp-content can run into gigabytes, and a single backup zip from a backup plugin can pass the 100 MiB block on its own. Keep uploads out of Git and serve or sync them separately.
Which .gitignore should I use for WordPress?
Start from GitHub’s maintained WordPress.gitignore template. It ignores core files, wp-config.php, the uploads folder, log files, .htaccess, the default Twenty themes and Hello Dolly. By default it still tracks every plugin and theme you install, and the comments in the file explain how to change that.
We tested it on 18 November 2026. On our WordPress 7.1.4 install it reduced 3,842 files to 106 tracked files, about 2.2 MB. It also committed two things we would never want in a repository: the site’s SQLite database file inside wp-content/database/ and a stray .zip archive sitting in the root folder. Our test site uses SQLite, so most MySQL sites will not have that exact database file, but backup plugins write archives and database dumps into wp-content all the time. These extra lines closed both gaps, and the tracked set dropped to 98 files:
# Add below GitHub's WordPress.gitignore template.
# Checked on 18 November 2026 with git check-ignore on WordPress 7.1.4.
# Database files, dumps and backup archives
/wp-content/database/
*.sql
*.sql.gz
*.zip
/wp-content/ai1wm-backups/
/wp-content/updraft/
# Generated or temporary folders
/wp-content/upgrade/
/wp-content/cache/
# Environment secrets
.envTwo of those folders are backup locations used by well-known plugins (All-in-One WP Migration and UpdraftPlus). If you use a different backup plugin, find where it writes and add that path. To check a single path, run git check-ignore -v path/to/file, which prints the rule that ignores it or nothing if the file would be committed.
How do I start a WordPress repository without leaking anything?
Order matters. The ignore file has to exist before the first git add, because Git keeps tracking any file it has already seen, even after you add it to .gitignore later. This is the sequence we ran on our test copy, from the WordPress root folder:
# Checked on 18 November 2026 with Git on macOS and WordPress 7.1.4.
cd /path/to/wordpress
git init
curl -o .gitignore https://raw.githubusercontent.com/github/gitignore/main/WordPress.gitignore
# paste the extra rules from the previous section into .gitignore
git add .gitignore
git add -A
git status --short | head -50 # read the list before committing
git check-ignore -v wp-config.php # should print the rule that ignores it
git commit -m "Initial commit: custom code only"Read the git status output line by line before the first commit. Anything that looks like a password, a key, a dump, an archive or a media file should not be there. If something slipped in, remove it from the index with git rm --cached <path>, add a rule for it, and check again. Then create a private repository on GitHub and push. It takes two minutes longer than pushing blind, and it is the step that prevents most of the problems in the mistakes list further down.
What are the ways to put a WordPress site under Git?
There are three common layouts. Pick by how much control you want over plugin and core versions.
Layout | What is in the repo | Good for | Watch out for |
|---|---|---|---|
Theme or plugin only | One theme or one plugin per repository | Freelancers, agencies shipping a theme, plugin authors | Site-wide config is not versioned |
| Themes, plugins, mu-plugins; uploads ignored | Most single sites with a developer | Plugin updates made in wp-admin drift from the repo |
Composer-managed (Bedrock style) | Your code plus | Agencies, teams, many environments | More setup, needs Composer on deploy |
WP Tavern’s Git and WordPress tips piece (2015, still accurate) makes the same case for keeping core out of Git and managing it as a dependency. Bedrock from Roots is the best-known Composer layout: core lives in web/wp, your content in web/app, settings come from a .env file, and plugins are pulled through a Composer mirror of the WordPress.org directory. Moving wp-content out of the default place is part of that layout, and our guide on moving the WordPress content directory explains the constants involved.
How do I deploy from GitHub to my WordPress host?
Push to GitHub, then let a deployment step copy the changed code to the server. Never edit files on the live server and never run git clone inside the public web root. GitHub Actions is free with standard runners on public repositories, and the Free plan includes 2,000 CI/CD minutes a month for private ones (pricing page checked on 18 November 2026).
Many managed hosts publish their own deploy action. WP Engine’s github-action-wpe-site-deploy is a good example. This is its basic workflow from the README, checked on 18 November 2026, with the install name left as a placeholder:
# .github/workflows/main.yml
name: Deploy to WP Engine
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: GitHub Action Deploy to WP Engine
uses: wpengine/github-action-wpe-site-deploy@v4
with:
WPE_SSHG_KEY_PRIVATE: ${{ secrets.WPE_SSHG_KEY_PRIVATE }}
WPE_ENV: your_install_name_hereThe private SSH key lives in the repository’s Actions secrets, not in the code. The action’s README notes that its default rsync flags exclude dot files, so your .git folder and .env file are not copied to the server. If you write your own rsync or SFTP step for another host, copy that idea: exclude .git, exclude anything secret, and make sure file ownership and permissions on the server stay correct after each deploy. Our WordPress file permissions guide lists the values to check.
Where should I test before deploying?
On a local copy first. Clone the repository into a local WordPress install, run the site with a copy of the production database, and only push once it works. Our sibling guide on installing WordPress on localhost covers the local setup. Bring the database down with wp db export on the server and fix the URLs locally with wp search-replace. The database goes from production to your machine, never into Git.
Does Git stop WordPress automatic updates?
Yes. WordPress core checks for version control before it runs background updates. In wp-admin/includes/class-wp-automatic-updater.php, the is_vcs_checkout() method looks for a .svn, .git, .hg or .bzr folder in the site folder and every parent folder above it. If it finds one, automatic updates are skipped, and Site Health reports that the folder was detected as being under version control.
We confirmed it on our test install on 18 November 2026. Before git init, nothing was detected. After it, is_vcs_checkout() returned true for both the site root and the plugins folder. That is deliberate: WordPress does not want to change files that Git thinks it owns. If you deploy from Git, this is fine, because updates should happen in the repository and ship through your deploy. If you keep a .git folder on a live server by accident, your site quietly stops receiving automatic security releases. The automatic_updates_is_vcs_checkout filter can override the check, but removing the stray .git folder is usually the better fix.
Common mistakes people report
These come up again and again in security research and developer forums. We checked each source on 18 November 2026.
- Committing secrets.
wp-config.php,.envfiles and API keys land in commits because the ignore rules were added after the first commit. GitGuardian’s 2026 report counted about 28.65 million new secrets in public GitHub commits in 2025. Fix: add.gitignorebefore the firstgit add, and rotate anything that was ever committed. - Deploying with git clone into the web root. The live site then serves its own
/.git/folder. Pen Test Partners reported in April 2020 that the GDPR.EU WordPress site exposed its.gitdirectory, and the repository included awp-configfile with the database password. Truffle Security later found 4,500 of the top one million websites exposing their.gitfolders. Fix: deploy with rsync or a host action that excludes.git, and block.gitpaths in the web server config. - Updating plugins in wp-admin on a Git-deployed site. The next deploy puts the old version back, or the repository and server drift apart. A Roots community thread answers this directly: never make changes in production that are not in the repository, and bump versions in
composer.jsoninstead. The Protect Version Controlled Updates plugin was built to block exactly this, though it was last updated in 2016. - Committing uploads and backups. Repositories grow past GitHub’s recommended size, clones get slow, and any single archive over 100 MiB is rejected, per GitHub’s large files limits. Fix: ignore
wp-content/uploadsand every backup folder before the first commit. - Leaving a .git folder on the live server and wondering why updates stopped. As tested above, WordPress turns off automatic updates when it finds version control in the site folder or any parent folder. Fix: deploy files only, or update through your repository on purpose.
How do I block the .git folder on the web server?
Add a deny rule even if you think the folder is not there. On Nginx, inside the server block:
# Checked on 18 November 2026: deny any path containing /.git
location ~ /\.git {
deny all;
}On Apache, in the site’s .htaccess or virtual host (needs mod_alias, which is on by default on most hosts):
# Checked on 18 November 2026: answer 404 for any /.git path
RedirectMatch 404 /\.gitThen request https://your-site.example/.git/HEAD in a browser. A 403 or 404 is what you want. If you see a line starting with ref:, the folder is exposed.
What are the pros and cons of putting WordPress on GitHub?
Done the right way (your code only, private repository, deploy step), the trade-off clearly favours Git for anyone who writes code. Done the wrong way (the whole site, uploads and config included), it adds risk without adding much.
Pros | Cons |
|---|---|
Full history of every code change, with who and why | A learning curve if you have never used Git |
Roll back a bad theme or plugin change in seconds | Not a backup: no database, no uploads |
Pull requests let a second person review changes | Secrets leak easily if ignore rules come late |
Repeatable deploys to staging and production | Plugin updates must go through the repo, not wp-admin |
Free private repositories and CI minutes on the Free plan | Automatic updates turn off if .git sits in the site folder |
If you are not a developer and never edit code, GitHub adds little for you. A good backup plugin, your host’s staging site and careful updates will serve you better.
Frequently asked questions
Can I host a WordPress site on GitHub Pages?
No. GitHub Pages serves static files only and cannot run PHP or a database. You can export a WordPress site to static HTML with a static site plugin and publish that, but then the WordPress admin is not live.
Should I commit WordPress core to Git?
Usually not. Core is identical for everyone and updates on its own schedule. Pin the version with Composer, or let your host manage it, and keep only your own code in the repository.
Should the uploads folder be in Git?
No. Images and documents are large binary files that bloat the repository. Sync uploads between environments with rsync, your host’s tools or an offload plugin, and back them up separately.
Is it OK to commit wp-config.php to a private repository?
Not with real values in it. Commit a version that reads database credentials and salts from environment variables, or commit only a sample file, and keep the real values on the server.
How do I move my database between local and live with Git?
You do not. Export it with wp db export, copy the file outside the repository, import it with wp db import and fix URLs with wp search-replace. Database dumps never belong in Git.
Do premium plugins belong in a public repository?
No. Keep paid plugins out of public repositories and pull them in with your vendor’s licence system or a private package source. Many paid plugins also store licence keys in files or the database.
How we tested this guide
On 18 November 2026 we copied a WordPress 7.1.4 test install (PHP 8.5, SQLite database integration plugin), ran git init, applied GitHub’s current WordPress .gitignore template and counted the tracked files and their size, then added our extra rules and ran git check-ignore on each path. We called WP_Automatic_Updater::is_vcs_checkout() with WP-CLI before and after creating the .git folder, and read the method in core. GitHub’s limits, push protection defaults and pricing come from GitHub’s documentation and pricing page, and the deploy workflow comes from WP Engine’s action README, all read the same day. Sizes on your site will differ with the plugins, themes and uploads it has.
Plugins we build and run
We maintain these ourselves, which is why we can support them on your site.
- BuddyNextThe self-hosted community engine for WordPress
- BuddyXFree community theme, Pro when you outgrow it
- ReignPremium community theme. Add pieces, build anything
- JetonomyCommunity forum and Q&A for WordPress
- EventonomyEvents and RSVPs for WordPress communities
- LearnomyCourses and learning communities on WordPress
- ListoraDirectories and listings your members can browse
- SnipShareCode sharing built for developer communities
- WB Ad ManagerAd placements that turn traffic into revenue
- WP Career BoardA job board your community actually uses
- WP Sell ServicesSell services with offers, orders, and payouts
- MediaVersePhotos, video, and media albums for members
- WB GamificationPoints, badges, and rewards that keep members active
- Product RoadmapPublic roadmaps with voting your users trust
Related Posts

LiteSpeed Cache Vulnerability CVE-2026-93389: Check Your Version and What Was Exposed

Freemius SDK Stored XSS: How to Find Every Bundled Copy on a Client Site (Anything Under 2.13.5)
