How to Use Git Version Control in cPanel

How To Use Git Version Control in cPanel

Do all of your Git stuff right from within your hosting account? Yes. With cPanel you can now host a private or public repository without paying premium costs to third party Git hosting services like GitHub or BitBucket. (These steps will also work in cPanel on managed dedicated server hosting.)

cPanel creation is no longer unlimited. Learn more about cPanel Pricing Changes and related FAQs.

While Git Version Control is available in all of our hosting accounts, we’d recommend a VPS or Dedicated hosting package, so you can exercise more control over individual shell user privileges. This is especially important if you plan on having other users access your Git repository.

Be very careful creating a repository in a directory that already contains files. If, for some reason, you delete the repository from cPanel, the whole directory will be erased!

How to Create a Git Repository with cPanel

In this first part we’re creating a new repository. Later, we’ll show you how you can “clone” an existing repository instead.

If you’re creating a repository for the first time, you’ll be prompted to fill in the necessary fields right away. Otherwise, you’ll just need to click the blue Create button. These steps are detailed below:

  1. Log into cPanel
  2. Select Git Version Control under Files
  3. Click Create (if you haven’t created any repositories yet, you’ll be skipped ahead to the next step automatically)
  4. Toggle off the Clone a Repository button
  5. Fill in the file path to the new repository
  6. Provide a name for the repository as it will appear in your cPanel interface
  7. Click Create at the bottom

Now, cPanel will create the repository and provide you with some helpful Git commands you can run in a shell session in order to use this repository.

How to “Clone” a Git Repository in cPanel

Instead of creating your own Git repository, you can “clone” a repository that already exists out on the Web: for example, from the popular Git hosting site GitHub.

  1. Log into cPanel
  2. Select Git Version Control under Files
  3. Copy the clone URL into the Clone URL
  4. Fill in a file path for the repository (remember the cloned repository provides its own directory)
  5. Fill in a name for the repository as it will appear in your cPanel interface
  6. Click Create

Now you have successfully cloned a repository into your hosting account. This is a great way of cloning in a homepage you may have under version control at a different location or just a repository of various scripts or assets you may need for a project.

How To Clone a Git Repository To Your Local Computer

One of the most important aspects of managing a project in Git is being able to sync the remote repository with your local work.  This process will be a little different for VPS and shared hosting users.

The best way to clone a Git repository is to use the default SSH connection.  While your VPS uses the default port 22, the shared hosting server uses port 2222.  The only difference here is where you state what port you want to use.

For VPS users, the clone command will look like this:

git clone ssh://[email protected]:/home/userna5/test-git-site

For shared hosting, you will just need to specify the port:

git clone ssh://[email protected]:2222/home/userna5/test-git-site

“Permission Denied” Error

If you encounter a “permission denied” error when trying to clone a private repository (from GitHub or other provider) you will need to register an SSH key on your server for this purpose. 

Why Create a Git Repository in cPanel

It’s true that you can launch your own repository wherever you have Git installed. However, cPanel makes the process much easier by creating the repository and the necessary executable files to save and launch your project right away.

But, if you want to do it the long way, you can follow our article on using Git to publish files.

Manage Projects With Ease

We’ve gone into some depth explaining how Git works in our Git tutorial series. But if you want a closer look to see how Git can work for you, you can now easily set up a Git repository with any of our cPanel hosting accounts.

Helpful Commands Delivered

cPanel gives you the essential commands you’ll need to get started the instant you’ve created your repository.

Let us Know What You Think

Have you been using Git for a long time, or you just getting started?

If you need any further resources about Git, be sure to check these out:

We’re excited that our hosting customers can now easily set up and use Git repositories from within cPanel. If you have troubles along the way, be sure to leave a comment and let us know.

CM
Christopher Maiorana Content Writer II

Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog.

More Articles by Christopher

11 thoughts on “How to Use Git Version Control in cPanel

  1. Pushing the client out to a 3rd party to resolve “Permission Denied” error is only slightly helpful.
    How do you use or apply the keys once created on the InMotion server?
    What is the proper command structure to clone the git repo from the InMotion server to your local device (laptop / desktop) using the ssh key / ID / password ?

    1. Are you on shared hosting? If so, you will need to specify port 2222 when attempting to clone your repository:

      git clone ssh://<username>@<server>:2222/path/to/<git-repository>
      

      After that, you should be able to push and pull with no problems. The connection information will be saved in the local Git configuration.

    1. Hello! I apologize, I’m not entirely sure what you need assistance with. Could you please explain your issue in more detail? We’ll do our best to assist!

  2. Would the user have to provide the same credentials as the cpanel login to access the git repository?
    Clearly this would be a problem if we can only access the git repository with an admin login…

    1. That depends on what kind of access you require. Do you want other users besides yourself to have access, and if so what kind? Git supports SSH access, which is likely the most straightforward option, Git as a protocol, and HTTP.

    1. Hello James,

      Thank you for your question. Unfortunately, it appears that the cPanel Git Version control utility cannot be used to create a bare repo. However, you should be able to create a bare repo elsewhere and clone it using the utility.

      I do hope this helps,

      Best Regards,
      Alyssa K

    1. Cloning a private git repository cannot be done with the standard “git://” nomenclature. You will need to use “git@”. I found the information for this answer here.

      “Private clone URLs take the form [email protected]:username/repo.git – perhaps you needed to use git@ rather than git://?

      git:// URLs are read only, and it looks like private repos do not allow this form of access.”

Was this article helpful? Join the conversation!

Questions about our MailChannels Deployment? We have answers and are here to help!Learn More
+