How to Clone a GIT Repository

Learn how to clone your new repository to your local machine

This tutorial explains how to clone your GIT repository to your local machine. This way you can work and develop your project locally.

Find your SSH key in the SG-Git interface

The GIT system uses the SSH protocol to transfer data between the server and your local computers. This means that in order to clone the repository you need to have SSH access to your SiteGround hosting account. To see the SSH key, you can click on the Info button next to the entry for your repository.

A new window will appear in which you will be provided with your SSH key and information about the folders excluded from the repository.

Due to security reasons the password for your SSH key will not be displayed in the tool. If you do not know your SSH key password, you will have generate a new key from the SSH/Shell Access tool in cPanel. You can check our detailed SSH tutorial for more information how to manage your SSH keys.

Commands to clone locally and commit back online

You can use Linux, Windows and Mac to clone the repository. This tutorial explains the Linux commands for cloning your GIT repository. In addition, in the pop-up you will get the command line that you can simply copy and paste in your terminal. In this example the command will clone the repository for the main WordPress site:

You computer will need several minutes to clone the repository. After that you should see your application copied on your local computer. If you want to clone your site to a specific folder you can use the following modified command:

The above command will clone the repository and the application will be saved on your local computer in the "/home/user/Desktop/mainsitegit" folder. At this stage the site will be downloaded to your local computer and you can edit your files via your favorite editor. To commit the changes to your local GIT repository you can use the following command:

The above command will commit the changes to your local repository and the comment will be added to the GIT logs. To push the changes to the server you have to use the following command:

The system will connect to the server and upload the files that have been modified on your local computer.