How do I use the Git version control system on cPanel?

Procédure

What is Git?

Git is a powerful tool for managing the versions of your application files in a decentralised way. It makes it easy to store and switch between several versions without having to manually manage the location of each version of each file.

Git introduces the notion of a repository, which is a location where your entire project is stored. This can be a local location (a folder on your PC) or a remote location (hosted on your cPanel account or on github.com, for example).

Deploying a Git repository on your PC to cPanel

If your Git repository is on your PC, you can use Git's "push" command to deploy your application to your cPanel formula. To do this

1. Make sure that your SSH connection between your PC and your cPanel account is working. Refer to the documentation concerning the SSH connection on cPanel for all the details.

2. Log into your cPanel account and go to the " Git™ Version Control " icon.

How do I use the Git version control system on cPanel?

3. Click the " Create " button to create a new Git repository on your cPanel account.

How do I use the Git version control system on cPanel?

3. Complete the form as follows:

  • (1) Disable " Clone a Repository " as we are not going to copy a remote repository.
  • (2) In " Repository Path ", enter the location you wish to give to your application in your web hosting package.
  • (3) In " Repository Name ", enter a name for your Git repository.
  • (4) Click on " Create ".

How do I use the Git version control system on cPanel?

5. You will then be provided with the details of your Git repository in your cPanel account.

How do I use the Git version control system on cPanel?

6. On your PC, open your terminal and go to your Git project folder.

How do I use the Git version control system on cPanel?

7. Add your Git repository on cPanel as a remote mirror of your local repository with the " git remote add origin " command.

How do I use the Git version control system on cPanel?

Notes:

  • The URL format is as follows: ssh://@ /home//path/in/your/account/ftp.
  • If you use a CDN such as Ipxchange or Cloudflare, you cannot use "yoursite.com" as this is associated with the IP address of the CDN server and not the cPanel server. Instead, you must use "ftp.yoursite.com" or the host name of your cPanel server.

8. Send the "master" branch of your local Git repository to your remote Git repository using the " git push origin master " command:

How do I use the Git version control system on cPanel?

And that's it, your local Git repository is now published on your cPanel account.

Deploying a remote Git repository on your cPanel account

However, it is possible that your Git repository is not located on your PC. This is the case, for example, if you work in a team and each developer contributes to a Git repository located on a Gitlab server or on Github.com.

1. Log in to your cPanel account and go to the " Git™ Version Control " icon.

How do I use the Git version control system on cPanel?

2. Click the " Create " button to create a new Git repository on your cPanel account.

How do I use the Git version control system on cPanel?

3. Complete the form as follows:

How do I use the Git version control system on cPanel?

  • (1) Enable " Clone a Repository " as we will be copying an existing repository.
  • (2) In " Clone URL ", enter the URL of your remote repository. In the case of Github.com, this can easily be found from the repository's main page:
    How do I use the Git version control system on cPanel?
  • (3) In " Repository Path ", enter the location you want to give your application in your web hosting package.
    (4) In " Repository Name ", enter a name for your Git repository.
    (5) Click on " Create ".

Deploying a remote Git repository on your cPanel account from the terminal

You can also use the terminal associated with your cPanel account to deploy a Git repository.

To do this, from your SSH console or the cPanel web terminal, move to the folder in which you want to place your Git repository:

cd ~/public_html/

Next, download your remote repository using the git clone command:

git clone ssh://git@github.com/moncompte/hello-world.git

If your repository requires the use of a specific private key, you can generate one with the following command:

ssh-keygen -t rsa

You can then display the associated public key using the following command:

cat ~/.ssh/id_rsa.pub

You can then add this key to the deployment keys of your remote repository. Example on Github :

How do I use the Git version control system on cPanel?

Conclusion

You can nowuse Git Version Control to clone or create a new repository on your cPanel web hosting. You also know how to clone a cPanel repository using your SSH Terminal or Putty software.

Don't hesitate to share your questions and comments!

Rate this article :

This article was useful to you ?

Article utileYes

Article non utileNo

Vous souhaitez nous laisser un commentaire concernant cet article ?

Si cela concerne une erreur dans la documentation ou un manque d'informations, n'hésitez pas à nous en faire part depuis le formulaire.

Pour toute question non liée à cette documentation ou problème technique sur l'un de vos services, contactez le support commercial ou le support technique

MerciMerci ! N'hésitez pas à poser des questions sur nos documentations si vous souhaitez plus d'informations et nous aider à les améliorer.


Vous avez noté 0 étoile(s)

Similar articles

1mn reading

How do you change the style of your cPanel?

2mn reading

How do I password-protect a directory in cPanel?

2mn reading

How do I create additional FTP accounts in cPanel?

3mn reading

How do I create custom error pages in cPanel?


Ask the LWS team and its community a question