Using WordPress with Git – which files should I ignore?


For the past 6 or so months I have been working on Laravel projects that are closer to web apps rather than full, content managed sites.

Recently I’ve started a WordPress project and there’s something that baffles me, how do you use Git with WordPress?

I ask because in Laravel you can basically push everything asides from node_modules, storage and the composer vendor folder.

I have also read that it is not a good idea to store wp-config in your repository, it’s a strange one as Laravel uses an .env file to similar effect.

I found the following .gitignore



Laravel’s .env file contains sensitive data just as WP’s wp-config.php so we don’t usually push it into the repo.

As to how I use Git with WordPress:

  • I exclude the wp-config.php file, the developer cloning the repo doesn’t need it anyways: they can fill in the credentials themselves when working on the project on their local development environment. Another good reason to leave this file out is you don’t want to expose your site’s details (host, database name, username, password, salts, etc) to the world.
  • I exclude the uploads folder. The reason is that while developing we usually add dummy images to our posts and pages, images that won’t be used at all when the site is finally ready for production so there’s no reason to “pollute” the repo with these.

One of the things I love about Laravel is that database changes can also be tracked thanks to migrations. WordPress, on the other hand, doesn’t have anything like that so you’ll have to find a plugin (or some other mean) to keep your local database in sync with the staging one.


Since you updated your question to ask which files should be specifically excluded from the Git repo, I think the ones you posted from that .gitignore file you found are good enough. I don’t see the need to ignore the readme.txt file though but that won’t do any harm either.

Answered By – cabrerahector

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published