Updated on Nov 16, 2016
VersionPress comes with several WP-CLI commands for more advanced users and those who prefer to do things via the command line. WP-CLI is available on all of our Shared Hosting Servers always up to date as new WordPress versions also require the latest WP-CLI version.
To use WP-CLI with VersionPress, you will need to navigate to the root of your website and execute the appropriate commands there. If VersionPress is not activated you will need to use --require to execute a specific WP-CLI command.
If you need guidance, you can always use wp help for the latest available commands.
vp config - Configures VersionPress. For more information on the configuration, you can check the official documentation configuration.
vp undo - Undo a commit.
This does the same as clicking the Undo this button in the admin area. In case there is a conflict with a commit, the same rules as the ones explained in the Undo and Rollback tutorial apply.
In order to get the commit as an argument you will need to also execute
and copy the SHA1 b236229495a54a3b10bb7113b0fbd8ce392fcc2b or the first 7 characters of it.
wp vp rollback b236229
If you have uncommitted changes on your website, you will receive the following error.
vp rollback - Reverts site to a previous state.
It is the same action as clicking the Roll back to this button in the admin screen.
wp vp rollback b236229
vp restore-site - Restores site from a Git repository.
You will typically use this command when you want to restore the database after something has broken it. Alternatively you can always use the last daily backup if the time period passed corresponds to your needs.
If you have completely removed your database wp vp restore-site will re-create the database tables much like a restore from a backup would work.
You will have to include the --require=... parameter because WP-CLI will not be able to detect the vp command on its own.
wp vp restore-site --siteurl='http://localhost/mysite' --require=wp-content/plugins/versionpress/src/Cli/vp.php
vp clone - Clone the site to a new folder, database and Git branch.
vp pull - Pulls changes from another site instance and creates a merge if there is need for such.
vp push - Pushes changes to another site instance. Does not create a merge.
vp apply-changes - Applies changes found on the disk to the database which is particularly useful after resolving a merge conflict.
With this command, you can check if all of the requirements for using VersionPress are met on the environment you wish to use it. All Shared Hosting FastComet servers meet the requirements for VersionPress, so you will need to use this only if you are using external resources.
If you are having issues with the execution add the —require= parameter.
We hope this tutorial will prove helpful to those advanced users who decide to use WP-CLI in order to manage their VersionPress functionality.