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.
# ignore everything in root directory, except: /* !wp-content/ !database_dump.sql !.gitignore # ignore everything in wp-content directory, except: wp-content/* !wp-content/plugins/ !wp-content/themes/
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.
#!/bin/sh mysqldump -u [dbuser] -p[dbpassword] [dbname] > /absolute/path/to/wordpress/root/database_dump.sql cd /absolute/path/to/wordpress/root git add database_dump.sql