How to Clone a GIT Repository

Learn How to clone your new repository to your local computer

To start working on your project locally, first you need to clone your GIT repository.

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 your SSH key, you can click on the Info button next to your repository.

Once you click on the Info button you will be provided with your SSH key and information about the folders excluded from the repository.

WarningDue 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. Please 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. In this tutorial, we will show you 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:

git clone ssh://username@siteground199.com:18765/home/username/public_html

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:

git clone ssh://username@siteground199.com:18765/home/username/public_html /home/user/Desktop/mainsitegit

The above mentioned command will clone the repository and the app 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 favourite IDE. To commit the changes to your local GIT repository you can use the following command:

git commit -a -m "Commit comment."

The above mentioned 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.