34SP.com
  • Domain Names
  • Hosting Plans
  • Support
  • Contact
  • Login

Knowledge Base

  • Domains
  • Professional Hosting
  • Universal Hosting
  • Reseller Hosting
  • VPS Hosting
  • Dedicated Servers
  • Billing
  • Account Management
  • WordPress Hosting
  • Website Builder
  • View All

How to get started with Git

Applies to:
WordPress Hosting

Difficulty:
Easy

Time Needed:
10 minutes

Introduction

With WordPress Hosting, you can use version control systems including Git and SVN to manage your website files.

Article Contents

  • How to add a Git repo
  • How to set up your Git repo
  • How to push a Git repo

Please note: To use Git, you need to ensure FTP is unlocked. For help on how to use FTP Lock, please read 'How to lock and unlock FTP access'.


How to add a Git repo

Step 1

SSH into your site

Firstly, you'll need to SSH into your WordPress Hosting container and navigate to the /httpdocs folder, for the site you wish to add.

For a guide on how to SSH into your WordPress Hosting container, please read 'How to login to WordPress Hosting using your SSH key'.

SSH into your site

Step 2

Add your Git repository

To create a new repository, type the following command:

wp git add

This will trigger the creation of a new git repo to be built in:

/var/repos/YOURSITE/

The new repo will be created with both a master and staging branch, both of which will be empty on creation.

Add your Git repository

How to set up a Git repo

Step 1

Clone your repo

After you have created a new repo, go to your local files and navigate to where you want to create the local version of your site.

You can then clone your repo by entering the following command:

git clone ssh://USERNAME@YOURSITE/var/repos/YOURSITE

Clone your repo

Step 2

Set up staging

After your repo has successfully been cloned, simply view your local files by stepping into your newly created folder which will be at:

/YOURSITE

You can then set up 'tracking' for your staging branch. This means that when you push and pull on the staging branch, it automatically pushes and pulls to your staging site. To set up your staging branch with tracking, enter the following command:

git branch --track staging origin/staging

Set up staging

Step 3

Fetch & pull

Then enter the following command:

git fetch --all

After the fetch is complete, pull with the following command:

git pull --all

After your pull is complete, you are ready and commit, push and pull any files you want.

As WordPress Hosting automatically updates your themes and plugins, we recommend only committing files you wish to update yourself (such as custom themes and plugins) to avoid conflicts.

Fetch & pull

How to push a Git repo

Step 1

Pushing your changes to staging or master

To push your local files, simply enter the following command.

git push

If you commit changes on the master branch and push them, those changes will be pushed to your live site.

Similarly if you push commits made on the staging branch, those changes will be pushed to your staging site. For more details on staging sites, please read 'Creating and accessing a staging area'.

Please note: When you push files, they will overwrite existing ones on your server.

Pushing your changes to staging or master

Was this article helpful?

49 people found this article helpful
Hosting made with ♥ in Manchester
34SP.com
Products
  • Domain Names
  • Professional Hosting
  • Universal Hosting
  • WordPress Hosting
  • Reseller Hosting
  • VPS Hosting
Support
  • Support Centre
  • Support Charter
  • Knowledge Base
  • System Status
  • Contact Us
  • Arrange Call Back
Company
  • About
  • Sustainability
  • Price Promise
  • Careers
  • Customer Stories
  • Sitemap
  • Privacy Policy
Follow
  • 34SP.com Blog
  • Twitter
  • Facebook
  • Instagram
  • Youtube
  • Items (£0.00)
  • Proceed to checkout
Download Video
34SP.com