If you're a WordPress developer, chances are from time to time; you just want a…
More and more, Git is becoming a de facto standard for version control in web development. But keeping git commits in sync with various WordPress sites can be a bit difficult. Revisr makes this easy and allows you use git to manage your WordPress files as well as your database, as well as giving you a GUI to manage Git commits and branches.
What’s it Do?
Revisr adds a GUI to the WordPress admin which allows you to view and track changes to a Git setup in the root directory of your WordPress install. You can use this to commit new changes, switch to new branches, and revert to old commits. Revisr also hooks into your database, allowing you to automatically go back to a previous version of the database, or switch to different databases on different branches. And if you have a remote repository set up already, you can easily connect your local and remote environment, and then push changes up with a click of a button. There is also an SSL option to connect to the remote server if you are unable to get it up and running.
Revisr is for advanced users who are already using Git comfortably. It can be a bit tricky to set up but works fairly well once you do.
How’s it Work?
The first step is to make sure that you have a Git repository set up in the root directory of your WordPress install. This means it can’t be installed in just a theme directory, it needs to encompass the entire WordPress installation. After you have this setup, you can go ahead and install and activate the plugin. If you are seeing that the Git repository cannot be found, you may want to check out this forum thread for some help.
The first thing you’ll want to do is set up the plugin. Go to Revisr -> Settings in the WordPress admin and enter your Git username and email. As an added bonus, you can also choose any files you want to add to .gitignore (which will not be included in version control) right below this and switch on or off email notifications.
We will skip over the “Remote Repository” tab for now, and go to the “Database” tab. This is for setting up Revisr to backup and manage your database as well. One thing I’ll mention, if you are using MAMP, make sure your Apache and MySQL database are set to “default ports” (meaning 3306 or something similar for MySQL). I initially had my MySQL server set up on port 8889, and backups were not working until I switched it over. In the Database settings window, enter in the path to MySQL on your server. For MAMP and WAMP users, the recommended paths are suggested below this field, which worked fine for me. You can also choose to “Reset database when changing branches”, which means that different Git branches will use different versions of your database if you need to use this for testing.
Now it’s time to perform our first commit. Head on over to Revisr -> Dashboard. Here is where you can manage your Git repository. You can see a list of your commits, and use buttons on the side to add a new commit, revert to an old commit, backup your database, or push changes to a remote server. For now, click “Commit Changes” to start our first commit. The next screen will show the details of your commit. Give it a title, and then choose whether or not you want to backup your database with the commit. Below this, you’ll see a list of unstaged (not ready for the commit) and staged (ready for the commit) files. Simply move any files you want to bundle into your commit over to the Staged section. When you have added everything, just click “Commit Files.” That’s it. The commit will be added to your git repository, and will now be shown in the dashboard. Every time you want to add a commit, this is all you have to do, without having to go to the command line.
To revert to an old commit, you can go to Revisr -> Commits. For each commit, you will see a list of links. “View” will give you a diff file, which shows you which files were changed and the additions and deletions that were made. If you’ve ever used GitHub or Bitbucket, this interface should be familiar to you. “Revert Files” will roll your site back to a previous commit if you have a need, and “Revert database” will do the same, except with your database files. If at any time you revert and want to undo this, you can go to the Dashboard and simply click undo, which will bring everything back to the way it was.
You can also manage Git branches in Revisr by going to Revsir -> Branches. Here you can create a new branch, or check out any branch that you are working on, or switch back to the master. You can also delete any of your branches. If you chose to reset database when changing branches, then your posts, pages, media, etc. will be preserved from branch to branch. So if you are working on a feature that requires a certain post, you can easily create a test on a branch, knowing that the feature will work and that post will disappear when you switch back to your master.
Obviously, a lot can be done here. You can completely manage your Git repository without having to go to the command line. Revisr is also set up to sync databases and files between a local and remote environment. This can be tricky, and there are always problems with deployment. I wouldn’t recommend hooking into your live site with Revisr, but rather a staging site somewhere, at least at first. If you have already connected your local server to a remote Git repository on your server as “origin,” then you should be able to just click “Push Changes” in the Dashboard and changes will be pushed up. If you are having trouble connecting, then you can go to Revisr -> Settings and switch to the “Remote Repository” tab where you can enter in the name of the git repository on your server, and enter in a direct path using SSL (https) or SSH (git@) to your Git file, which should help the two connect. Once it’s set up, you can also choose to automatically push or pull commits when they are made. I won’t go into too many details here, as it’s a fairly advanced topic, but you can visit the Revisr documentation for more information.
Revisr keeps things fairly simple, but it is still very powerful. Use it to manage your version control in WordPress without a hassle of the command line, and with some very intelligent fallbacks and set-ups.
Costs, Caveats, Etc.
Revisr is free and in active development. If you are having problems, you can post in the support forums to get help from the developers, or send a message to get direct help from the team. The plugin has many more features to come I’m sure, and gets simpler all the time.