DEV Community

Cover image for Git + WordPress
Lukas Bocanegra
Lukas Bocanegra

Posted on

Git + WordPress

Hi there 👋! I'm asking for your help again... I would like to ask if you know how to version a WordPress project with Git.

It's enough and safe with adding the files to a private repo?
Which files should have on the .gitignore file?
How can I version the Database too?

Thanks a lot for your help! 🤖

Top comments (2)

Collapse
 
drawcard profile image
Drawcard • Edited

There are two major components to WP: the site theme files (ie PHP scripts on your web server) and the database (where the actual content of your site is stored). Versioning the database is not recommended, because it is so complex and has heaps of transient data. You'd be better off taking regular snapshots of that to restore anything.

However, you can version the website files - things like the theme, plugin directory, etc. as well as critical files like wp-config.php.

Here is a good guide for a plugin based solution: kinsta.com/blog/wordpress-version-...

However if you want something simpler (say to manage a theme) you can create your own git repo privately, and then clone a bare copy of it to your web server: culttt.com/2013/04/08/how-to-deplo...

Collapse
 
bocanegradev profile image
Lukas Bocanegra

Thanks for your explanation, I'll check that info 🤘