< All Topics
Print

WP-CLI Support

Git Updater works with the WP-CLI commands for wp plugin and wp theme for updating, listing, etc. This is not a premium function.

Git Updater creates subcommands under the wp plugin and wp theme commands. The information on the subcommands can be found from the following commands.

wp plugin install-git --help
wp theme install-git --help

wp plugin branch-switch --help
wp theme branch-switch --help

The syntax for the subcommands to install repositories via Git Updater is as follows.

wp plugin install-git <uri> [--branch=<branch_name] [--token=<access_token>] [--github] [--bitbucket] [--gitlab]
wp theme install-git <uri> [--branch=<branch_name] [--token=<access_token>] [--github] [--bitbucket] [--gitlab]

When using the install-git subcommand the following optional parameters are needed to install different branches, private repositories, or from self-hosted git installations.

Installing Branches

To install a specific branch, set the option --branch=develop or whatever the branch name is. The default is master.

Installing Private GitHub or GitLab Repositories

For private GitHub or GitLab repositories you can set an access token by using --token=my_super_secret_token.

Installing Private Bitbucket Repositories

For private Bitbucket repositories set --token=username:password. These are your Bitbucket username and app password with read access. Don’t forget to separate the values with a colon.

Installing from Self-Hosted Git Installations

For self-hosted git installations such as self-hosted GitHub or self-hosted GitLab, you must set the appropriate parameter. These parameters are optional for repositories on GitHub.com, Bitbucket.org, GitLab.com or Gitea.

--github
--bitbucket
--gitlab
--gitea
--gist

Branch Switching

To switch an installed repository to a different branch use the following commands. The <slug> for a plugin or a theme is similar. It will appear as the repository folder name. Both parameters are required.

The syntax for the subcommands to switch branches of repositories via Git Updater is as follows.

wp plugin branch-switch <slug> <branch>
wp theme branch-switch <slug> <branch>

Git Updater Commands

The following command is available to interact with the Git Updater plugin.

wp git-updater

Additional information can be obtained by using the standard wp help git-updater command.

The following subcommands are available.

wp git-updater cache <delete>
wp git-updater reset-api-key

wp git-updater cache <delete>

Using this command will delete the Git Updater cache. Caches will have to be reset at next load. Currently the only subcommand you can pass to wp git-updater cache is wp git-updater cache delete.

wp git-updater reset-api-key

Using this command will reset the Git Updater REST API key that is used for the RESTful endpoint. After reset, the new RESTful endpoint will be displayed.

Adding Credentials to Git Updater

If you want to set up a site completely using WP-CLI, you might need to add credentials. The proper key/value pairings are in Developer Hooks.

Here’s the wp-cli code used to install from a Bitbucket private repo:

Set the Pseudo-Token for the Bitbucket Account

wp site option update git_updater '{"bitbucket_access_token":"my-username:my-password"}' --format=json

Install theme from Bitbucket Private Repo

wp theme install-git https://bitbucket.org/my-username/my-theme --token=username:password

Install & Activate the Git Updater plugin

wp plugin install https://github.com/afragen/git-updater/archive/master.zip --activate

Table of Contents