When tracking WordPress with Git, you don’t really need to track the WP core files. Here’s the gitignore file I use when creating wordpress themes

10 responses to “.gitignore for WordPress Projects

  1. Update: I just loaded an updated version. I organized things a little more, and added more ignore’s for projects using Grunt (node/npm). Message me if you have any feedback.

  2. How do you handle plugins that require updating during development of a site. I currently have a local master and dev branch. When a plugin receives and update notification I update in the local dev branch and test then merge dev into master. Then I push master to remote and deploy.

    Is this the common way of doing it?

    Thanks,

    Landon

    1. I usually update the plugin and then commit the changes immediately with a message like “updated xyz plugin”. Alternatively, you could just ignore all plugins except for the ones you’re working on and avoid this altogether (my gitignore file makes it easy to do this).

      I generally don’t create a new branch for updating plugins. I only create new branches when I’m testing a new feature I’m working on that I’d like to keep separate from my working copy.

  3. Thanks for this post! I’ve just started working on WordPress themes, so I was looking for the best ignore file. Has anything changed for you since you originally posted, or is it the same for the most part? Thanks again!

    1. Hi Scott,

      I keep this file up-to-date with changes as I come across them. But lately I only use git within the theme directory that I am building, which keeps it simple. This .gitignore file is sort of a “catchall” file that handles everything. It works great if you need/want to track the entire WordPress install as a whole. On larger projects where I expect to build custom plugins on top of the theme, I’ll use this .gitignore file I’ve posted here.

      1. Great! Thanks for the quick reply. I’m only doing some basic builds, so I’ll likely just use it in the theme directory.

  4. Thanks William! Is this the updated version? Do you recommend putting this .gitignore in themes directory?

    1. Yes this is the updated version – it should be syncing with my Github snippets page. Also, this needs to go in the root directory of your site – where the main WordPress site in installed.

Leave a Reply

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