You questioned:
How to use wordpress with Git?
Actually your question is a bit wrong, and should actually be:
How to use Git with WordPress?
As git is for controlling versions so using it depends upon you what actually you want to take under version controlling. I personally develop WordPress themes and plugins so I control versions, specific to themes and plugins only.
For Themes
When developing a theme (i.e. my-theme
is the folder name), I get into it:
cd my-theme
git init
git add -A
git commit -m "Started developing the theme"
In this way I manage all the versions of my development phase to that particular theme. But in the meantime WordPress can be updated, several plugins can be updated, and the /uploads/
folder can be updated too – I don’t care actually. I just think about code and that’s all.
In some cases I want the database to be version controlled too. In that case I export all the database tables into a .zip
file and put it inside the theme into a _db_
folder and then add and commit.
For Plugins
Within my Plugin (i.e. my-plugin
is the folder name), I follow the similar steps to control versions of my plugin.
For whole WordPress Project
To control versions of the whole WordPress project, get into the project folder and initiate git there to catch all the changes to the project.
project\ .git\ wp-admin\ wp-content\ wp-includes\ ...
That’s all what came to my mind.