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.

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