A .gitignore file for multiple WordPress sites in one repo

After holding off for a while, I finally got round to moving all of my client projects into a single (private) GitHub repo and the whole process was a lot less painful than I expected it to be. In the end, I only had one issue and that was crafting my .gitignore file so that the WordPress core files for each project didn’t all get uploaded to my repo (that would be a sure way to upset the fine folks at GitHub). The file wasn’t too tough to get right, but I thought it worth sharing in case anyone else is struggling with the same thing.

So here is a .gitignore file that will exclude all WordPress core files from your repo so that only your themes and plugins will be uploaded – this works recursively, so that it will ignore all the copies of WordPress you have in the sub-folders of the repo.


.htaccess
wp-admin/
wp-includes/
wp-config.php
*/wp-content/uploads/
*/wp-content/blogs.dir/
*/wp-content/upgrade/
*/wp-content/backup-db/
*/wp-content/advanced-cache.php
*/wp-content/wp-cache-config.php
*/wp-content/index.php
*/wp-content/themes/index.php
*/wp-content/plugins/index.php
*/index.php
*.log
wp-content/cache/
wp-content/backups/
sitemap.xml
sitemap.xml.gz
wp-activate.php
wp-app.php
wp-blog-header.php
wp-comments-post.php
wp-config-sample.php
wp-config.php
wp-cron.php
wp-links-opml.php
wp-load.php
wp-login.php
wp-mail.php
wp-pass.php
wp-register.php
wp-settings.php
wp-signup.php
wp-trackback.php
xmlrpc.php
license.txt
readme.html

view raw

.gitignore

hosted with ❤ by GitHub

2 Thoughts

  1. This still includes a couple of core files named index.php. If I add index.php to the .gitignore it will then ignore them inside the folder for each individual plugin/theme. Is there a way around this?

Leave a Reply