Git updates: keep a theme in sync with a repository
Git updates (Baza Helper > Git updates, a Pro tool) installs a theme straight from a Git repository, so a deploy is a push. Before every update a zip of the current theme is saved, and Roll back puts it back.
Connect the repository
- Repository address (HTTPS): the address as you would open it in a browser. It must start with https://.
- Branch or tag: a branch name updates the theme with every new commit on it. A tag installs only that release.
- Theme to keep updated: the installed theme whose folder is replaced, or The active theme.
- Theme folder inside the repository: leave empty when style.css is at the top; otherwise type the subfolder path.
- Access token (private repository): leave empty for a public repository. Create a token that can only read this one repository (GitHub fine-grained with Contents: Read-only, GitLab scope read_repository, or a Bitbucket repository access token). It is saved encrypted and never shown again; Remove the saved token deletes it.
- User name only if your host asks for one. Leave it empty for GitHub, GitLab and Bitbucket.
- Saved copies to keep: how many of the newest backup zips are kept.
Save the settings first, because the buttons use what is saved. The site asks the repository over the plain Git protocol, with no vendor API, so any Git host that speaks it works.
Update and roll back
- Check now compares the installed commit with the latest one and shows a See what changed link when you are behind.
- Update now downloads the repository, checks the zip for unsafe names and size, and replaces the theme folder. The folder must hold a style.css with a Theme Name. If the swap fails the old folder is restored.
- Roll back installs the newest saved zip.
Automatic updates
Switch on Look for changes and update the theme automatically (WP-Cron) and choose How often: every hour, twice a day or once a day. Automatic updates start only after you have installed the theme from this repository by hand with Update now, so a wrong address can never replace a working theme on its own. The theme folder is replaced as a whole: changes made to theme files on the server are not kept.
Log
The Log shows the last 20 entries. A failed download says what each address answered, so you can see what is missing, for example a token that cannot read the contents.
Create the access token step by step
You need a token only for a private repository. For a public repository leave the token field empty. A token of another repository does not help and can even cause a “not found” answer from GitHub, so use a token made for this repository only. Baza Helper only reads: it finds the commit from the public list of links and downloads the archive of that commit. The token is stored encrypted and is never shown again.
Step 1: GitHub (recommended: fine-grained token)
- Open GitHub, then Settings > Developer settings > Personal access tokens > Fine-grained tokens, or go to github.com/settings/personal-access-tokens/new.
- Under Repository access choose Only select repositories, and select the one repository your theme is in.
- Under Repository permissions set Contents to Read-only. Metadata is added by GitHub as Read-only. Leave every other permission at No access.
- Choose an expiry date. When the token expires, the plugin reports that the repository rejected the token.
- Press Generate token, copy it, and paste it into the access token field in Git updates.
A classic token with the repo scope also works, but use it only when a fine-grained token is not possible, because it can read all your private repositories.
Step 2: GitLab
- Open the project, go to Settings > Access tokens, and create a project access token.
- Give it the scope read_repository and the role Reporter or higher, then set an expiry date.
- Copy the token and paste it into the access token field.
Step 3: Bitbucket
- Open the repository, go to Repository settings > Access tokens, and create a repository access token.
- Give it the read permission for repositories, and copy the token.
- Paste it into the access token field.
Common mistakes
- The token was made for a different repository, so GitHub answers “not found”. Make the token for this repository.
- The wrong repository was selected under Repository access.
- The token has expired. Make a new one, paste it, and save.
- The repository is public, but a token is saved. Remove the token: a public repository does not need one.
Token and what a sync replaces
A private repository needs an access token: see the article Git updates: access token for a private repository. Remember that Update now replaces the whole theme folder with the repository archive and that .gitignore is not read, so folders such as vendor/ or node_modules/ that are not committed disappear from the site. A zip of the current theme is saved first, and Roll back puts it back.
