lbreeze

Deploy your site with git

Get a git remote for your website and put changes live with git push, over the site's own SSH.

Every website can have its own git repository on the server. You clone it, work on your own computer, and a git push updates the live site's files. It works over the website's SSH, so it is available on plans that include SSH.

Before you start

git reaches your site over SSH, with the same key you use for SFTP. Set both up first:

  1. In your control panel, select My sites, then the website.
  2. Open the Files tab.
  3. On the SFTP access card, paste your public key and select Save keys.
  4. On the SSH card, tick Allow SSH to this site and select Save.

See Upload and manage your website's files for the details.

Get the git remote

  1. Open the website's Studio tab.
  2. On the Git remote card, select Show the git remote.
  3. The card says Repository made the first time, or Repository ready after that, and names the branch.
  4. Copy the git clone command it shows and run it on your computer.

Good to know: if SSH is off for the site, the button is greyed out and the card says why.

Put changes live

Work in your copy, commit, and push:

git add .
git commit -m "Describe the change"
git push

A push updates the live site's files directly. There is no separate publish step.

If somebody has edited files on the server since your last push, for example in the file manager or over SFTP, the push is refused rather than overwriting their work. To carry on, sign in over SSH, commit those changes in the site's public_html folder, pull them into your copy, and push again.

What is in the repository

The repository is the site's public_html folder, the part visitors see. wp-config.php and wp-content/uploads are deliberately left out, so your database password and your visitors' uploads stay on the server and do not travel with every clone. The card lists everything it leaves out under Not tracked.

git and your coding agent

The Studio tab also connects your own coding agent. The two are different routes:

  • A coding agent writes to the site's staging copy, and a person publishes it.
  • A git push goes straight to the live site.

Before a big change

Select Create backup on the site's Backups tab first. If a push goes wrong, you can bring back the files as they were.

Was this helpful?
Still stuck? Contact support.

More in Websites