Home
/
SiteGround Git Tool Tutorial
/
How to Clone a GIT Repository

How to Clone a GIT Repository

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 SiteGround Git Tool

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, go to your Site Tools > Devs > SSH Keys Manager. Choose the key you have created and go to the Action menu > Private Key:

A new window will appear in which you will be provided with your SSH key:

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 to generate a new key from Devs > SSH Keys Manager in Site Tools. You can check our detailed SSH tutorial for more information on 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 this example, the command will clone the repository for the main WordPress site. It is available in your Site Tools > Devs > Git > go to the Action menu for the corresponding repository > Git Info:

git clone ssh://username@server_name:18765/home/customer/www/yourdomain.com/public_html/

Your 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:

git clone ssh://username@server_name:18765/home/customer/www/yourdomain.com/public_html/ /home/user/Desktop/mainsitegit

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:

git commit -a -m "Commit comment."

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:

git push

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

Share This Article