wordpressgit

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

*.log
wp-config.php
wp-content/advanced-cache.php
wp-content/backup-db/
wp-content/backups/
wp-content/blogs.dir/
wp-content/cache/
wp-content/upgrade/
wp-content/uploads/
wp-content/mu-plugins/
wp-content/wp-cache-config.php
wp-content/plugins/hello.php
/.htaccess
/license.txt
/readme.html
/sitemap.xml
/sitemap.xml.gz

Solution

  • 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:

    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.


    Update:

    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.