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! ๐Ÿค–

Discussion (2)

drawcard profile image
Drawcard • Edited on

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:

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:

bocanegradev profile image
Lukas Bocanegra Author

Thanks for your explanation, I'll check that info ๐Ÿค˜