Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git and WordPress (+ managing plugins and media)

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.

like image 816
dani Avatar asked Jan 21 '10 12:01

dani


People also ask

What are the best Git plugins for WordPress?

VersionPress is one of the most versatile and comprehensive Git plugins for WordPress. It sets up a repository on your server and enables you to revert every change easily. This even includes rolling back the WordPress core after updates. VersionPress also enables you to easily branch and merge sites, even including the database.

What is this Wordpress plugin?

This WordPress Plugin lets you easily publish, collaborate on and version control your [ Markdown, Jupyter notebook] documents directly from your favorite remote Git platform, even if it’s self-hosted. Write documents in your favorite editor and just push to your remote repository to update your blog instantly

What is the best versioning tool for WordPress plugins?

Gitium, from Presslabs, brings Git-powered versioning of any changes to plugins and themes right to the WordPress admin dashboard. All plugin installations, code changes, and updates are automatically tracked and versioned in a repository hosted by the Git host of your choice, such as Bitbucket or Github.

How is a WordPress website developed?

This is actually how WordPress itself is developed, with contributors creating branches, working independently on their ideas, and then submitting proposed changes to the core platform. If you want to know more about how to use Git, there are several resources available online, such as Learn Git, and Try Git.


1 Answers

Regarding Concern1, you can isolate those micro changes in a branch.

Basically, your local repo has two branches:

  • one dedicated to your granular commits
  • one (master) for GitHub

You can push everything to:

  • your website, on a bare repo, and then clone it and checkout the "granular" branch.
  • GitHub, with master updated with the "real" commits.

To clean your history and build your real commits, you can rebase the granular branch on top of master in an interactive way:

git checkout master
git rebase -i granular

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 or cherry-pick some commits from granular to master.

There are several example of managing Wordpress with Git:

  • Keeping Wordpress up to date using Git (Apr. 2008)
  • Tracking WordPress with Git (Sept. 2008)
  • git by example – upgrade wordpress like a ninja (Sept. 2008)

The last link is the most detailed about the WordPress upgrade process, and ends also with a rebase of your modifications;

like image 72
VonC Avatar answered Oct 11 '22 01:10

VonC