I’d like to apply revision control – using git – to my WordPress-based website development.
Based on my concerns below, how do I go about?
Concern 1: Pushing “granular changes”
In this specific case, it is hard to mimic the webserver environment locally. Therefore, I would like to push changes very often. Could I push changes on a “sub-commit level” to the webserver to avoid “irrelevant” commits? (And do I have to set up a git repo on my remote webserver at all?)
Concern 2: Plugin and media handling
Previously, me and my colleagues have been installing/updateing plugins and uploaded media from WordPress’ admin interface. If I’d also like to keep media and plugins in sync, how would this be achieved?
I would appreciate any resources detailing how to set up a workflow which would allow me to keep all my files (WordPress + plugins, media, themes etc.) locally, while at the same allowing me to push “granular changes” to my webserver and “real commits” to Github.
Regarding Concern1, you can isolate those micro changes in a branch.
Basically, your local repo has two branches:
You can push everything to:
To clean your history and build your real commits, you can rebase the granular branch on top of master in an interactive way:
That was you pick, squash or edit commits made in granular, replaying a cleaner set of commits on master.
That rewrites granular history, but this is not too bad if nobody pull directly from this branch.
If you want to preserve the granular history, only
merge
orcherry-pick
some commits fromgranular
tomaster
.There are several example of managing WordPress with Git:
The last link is the most detailed about the WordPress upgrade process, and ends also with a rebase of your modifications;