WordPress .gitignore generator

For a whole site, wp-content, one plugin or one theme. Runs in your browser. Nothing you type leaves the page.

Pick what your repository holds and get a .gitignore that keeps WordPress core, uploads, caches and secrets out of Git, and keeps your own code in.

What does the repo hold?
Options
Track only wp-content. WordPress updates core itself.
.DS_Store, Thumbs.db, .idea/, .vscode/
Folder names, comma separated. Leave empty to track every plugin.
Folder names, comma separated. Leave empty to track every theme.
.gitignore
# .gitignore for a whole WordPress site (repo root = the folder with wp-config.php)
# Made with https://wppusher.com/tools/gitignore/

# WordPress core: WordPress installs and updates it, so keep it out of Git
/wp-admin/
/wp-includes/
/index.php
/license.txt
/readme.html
/xmlrpc.php
/wp-*.php

# Config and secrets that differ per server
/wp-config.php
/.htaccess
/.user.ini
/wordfence-waf.php
.env
.env.*
!.env.example
auth.json

# Uploads and files WordPress generates
/wp-content/uploads/
/wp-content/upgrade/
/wp-content/upgrade-temp-backup/
/wp-content/fonts/
/wp-content/languages/

# Caches and the drop-ins caching plugins write
/wp-content/cache/
/wp-content/et-cache/
/wp-content/litespeed/
/wp-content/w3tc-config/
/wp-content/wp-rocket-config/
/wp-content/advanced-cache.php
/wp-content/object-cache.php
/wp-content/wp-cache-config.php

# Backups, security logs and database dumps
/wp-content/ai1wm-backups/
/wp-content/updraft/
/wp-content/backups-dup-lite/
/wp-content/wflogs/
*.sql
*.sql.gz

# Dependencies
node_modules/

# Logs
*.log

# OS and editor files
.DS_Store
._*
Thumbs.db
Desktop.ini
.idea/
.vscode/
*.swp
*~

Before you commit

Three things the file won't do for you

It won't untrack files you already committed

A .gitignore only stops new files from being added. If wp-config.php or uploads/ is already in the repo, remove it from the index (the files stay on disk):

git rm -r --cached wp-config.php wp-content/uploads

If a secret was ever committed, change it. It's still in the history.

Check a path before you trust it

git check-ignore -v path/to/file prints the rule that matches, or nothing if the file is tracked. git status --ignored lists everything being ignored.

Some lines are judgment calls

The whole-site file ignores .htaccess because WordPress rewrites it. Delete that line if you hand-edit it. languages/ is ignored because WordPress downloads translations. Delete that line if you ship your own.

Then deploy it

Push to GitHub, and the site updates

WP Pusher installs a plugin or theme straight from GitHub, Bitbucket or GitLab and updates it when you push. It runs inside WordPress, so the server needs no Git and no SSH. It deploys plugins and themes, not WordPress core, which is the same line this file draws.

Download WP Pusher

Level up with WP Pusher

Take the pain out of WordPress development. Push your code to GitHub where it belongs and never again deploy files over FTP on cheap shared hosting.