Hugh Lashbrooke

Community builder by day, tabletop game designer by night.

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.

View this gist on GitHub

2 responses to “A .gitignore file for multiple WordPress sites in one repo”

  1. Toby Avatar

    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?

    1. Hugh Lashbrooke Avatar
      Hugh Lashbrooke

      Adding ‘/index.php’ should sort that out for you I think – haven’t tested it though.

Leave a Reply

Your email address will not be published. Required fields are marked *