WordPress: GIT usage with automatic database backups

It’s always difficult how to use git with wordpress the best way. First step should always be a global .gitignore file that ignores all core files and only adds plugins and themes to your repo. The core could always be restored by the wordpress github repo or direct download, so there is no need to add that overhead to your own repository.

I just wrote a small .gitignore file for my own projects. Thats a simple base you can extend for your own purposes.

An other typical problem is the backup of databases. WordPress theme options and of course content is always saved in the database, so we need every change in there, when we commit file changes. The easiest way to do so, is the git hook „pre-commit“. Just add this file to .git/hooks/ and edit your absolute paths. On every commit git will backup your database and add it to your repo.





Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.