Revisr – Git for WordPressBy Shaumik Daityari
If you’re a developer who uses WordPress, chances are that you probably try to implement processes in your development workflow into WordPress. One such process is the use of version control. At the very basic level, version control essentially creates checkpoints in your code, allowing you to go back in time if something goes wrong. Arguably, the most popular version control software today is Git.
Implementing such a system in WordPress is not difficult. You can create a Git repository to manage your WordPress source code (which is possible only on the self hosted version). Additionally, you can create a database dump and add it to the repository. Commits through time would track changes in your files and database.
Although Git repositories can be managed through an array of powerful commands on the terminal or GUI clients which do the heavy lifting, we are going to talk about Revisr in this post. Revisr is a plugin which helps you manage your files and databases within the WordPress admin panel.
Note: I suggest you go through an earlier post on the basics of Git to get familiar with the Git related terms that I am going to use in this article.
After installing and activating Revisr, you need to perform certain steps before the plugin does its work. In the admin panel, go to Revisr → Dashboard to initialize the git repository. Once initialized, it asks you to finalize settings (such as the name and email associated with your Git commits), before you can go back to the Dashboard page to commit.
Once you have confirmed settings, check the files that you want to stage for commit (Revisr selects all unstaged files by default) and commit them by adding a message.
Once you have made changes after a commit (like say, installing a new plugin), you can come back to the dashboard and create a commit again.
Branching Your Work
One of the most powerful features of Git is the ability to work with branches. The simplest way to understand a branch is to imagine it as a separate workflow. Git also allows you to merge branches.
Go to Revisr → Branches to view a list of branches, create, merge or delete them from within the section.
Since Git is a distributed version control software, you may have copies of your repositories on different systems, sometimes on the cloud. In Git, a ‘remote’ is what these copies are called.
If you have a copy of the repository on the cloud (GitHub, BitBucket or GitLab), you can manage the remote using Revisr. Just go to the Remote tab of the Revisr Settings and fill in the details. In this example, I have created a repository on BitBucket (replace [password] with your password).
Once you have entered the details of your remote, you can select ‘Push Changes’ under the ‘Quick Actions’ panel on the Revisr Dashboard. In our case, this is how the repository looks once we have pushed the code.
As houghtelin has rightly pointed out in the comments, please take care that your .git directory is not published to production when you are using Revisr. This directory contains some important information and you should definitely make sure it’s inaccessible to the public. There are a few different ways to do this, an easy way is to create an .htaccess file and instruct Apache to deny all requests to that URL.
Backup and Restoring the Database
In the introduction, I mentioned taking dumps of the database and attaching them to your regular commits. This is exactly what Revisr does. Before we proceed, you might want to have a look at the database structure of WordPress.
On the ‘Quick Actions’ panel on the Revisr Dashboard, you will find a ‘Backup Database’ button, which instantly backs up your database by creating dump files and committing it, according to the options set in the ‘Database’ tab of your Revisr Settings. Alternately, you have an option to back your database when you are creating a commit.
An error may occur if the correct path to MySQL is not set in the Revisr Settings. For instance, in MAMP, the path to MySQL is
Revisr creates a file for each table that is backed up from the database. Let us push and view the changes on BitBucket.
As you might have observed from the dashboard screenshot above, I was having trouble taking a backup of the database. I debugged the error by finding out that the MySQL path was empty. This was visible in the Help tab of the Revisr Settings page.
The help tab contains certain other information that might help you debugging your problems. You may also check the activity log in your Dashboard to find out what might be causing trouble.
There are many Git plugins for WordPress, and another popular option is VersionPress. While VersionPress focuses on changes on the site, Revisr gives more weightage to the development cycle (which should excite the developers). VersionPress came up with a detailed post on how the two are different.
Yet another version control management system for WordPress is Gitium.
What I mean to say is that whether you are a developer or just another blogger, managing your WordPress site through version control is never a bad idea. Although it might be a bit difficult to get used to, I assure you the benefits in the long run are going to be immense. At least, you wouldn’t be Googling frantically if you drop your database by accident!