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:
- Log into cPanel
- Select Git Version Control under Files
- Click Create (if you haven’t created any repositories yet, you’ll be skipped ahead to the next step automatically)
- Toggle off the Clone a Repository button
- Fill in the file path to the new repository
- Provide a name for the repository as it will appear in your cPanel interface
- 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.
- Log into cPanel
- Select Git Version Control under Files
- Copy the clone URL into the Clone URL
- Fill in a file path for the repository (remember the cloned repository provides its own directory)
- Fill in a name for the repository as it will appear in your cPanel interface
- 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.
Thoughts on “How to Use Git Version Control in cPanel”
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 ?
Are you on shared hosting? If so, you will need to specify port 2222 when attempting to clone your 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.
i can see git in files
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!
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…
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.
Is it possible to create a bare repo with Git Version Control in cPanel?
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,
How would you clone a private repository? Where/how would I put in my credentials to allow it?
Cloning a private git repository cannot be done with the standard “git://” nomenclature. You will need to use “[email protected]”. I found the information for this answer here.
“Private clone URLs take the form [email protected]:username/repo.git – perhaps you needed to use [email protected] rather than git://?
git:// URLs are read only, and it looks like private repos do not allow this form of access.”