The Git Version Control feature enables developers to host Git repositories on their cPanel accounts easily. Git can be used to manage any collection of files, including website files and assets, software development projects, and essential text files. The Git version control is handy for developers, making cloning repositories easier and more accessible to beginners. Visit cPanel Git Version Control to learn more.
I will introduce a simplified method for cloning your repository from GitHub:
1. Generate SSH Key
Delete the known_host file from the file manager --> .ssh folder.
and then open Terminal from your cPanel (if you don't have terminal access, ask your hosting provider)
Run the command below to generate a new SSH key and press enter thrice.
ssh-keygen -t rsa -C "your github email"
Copy the content to the .ssh folder from your cPanel File Root, Edit id_rsa.pub and copy the content.
2. Setup Deployment Key
Go to your git repository settings --> Deploy key --> add deploy keys --> and paste the copied content. And then, run the below command.
ssh -T [email protected]
If it returns this
Hi **username/repository** You've successfully authenticated, but GitHub does not provide shell access. You're ready to go.
3. Create Git Action to automate
To automate the deployment process, you must have a .cpanel.yml file in the top-level directory of your repository. Create a .cpanel.yml file and set up this code below:
--- deployment: tasks: - export DEPLOYPATH=/home/<username>/public_html # Add /<app_folder> if required - /bin/cp <file_name> $DEPLOYPATH #Copy specific file to destination from root - /bin/cp /<sub_folder>/<file_name> $DEPLOYPATH #copy specific file from source sub folder - /bin cp * $DEPLOYPATH #copy all from root - /bin cp /<sub_folder>/* $DEPLOYPATH #copy all from sub folder root - /bin/cp -r * $DEPLOYPATH #copy all recursively to $DEPLOYPATH
<username>with your cPanel username.
- Place the file at the root of your project
- The file must be in the repo before you clone it with cPanel
- Be sure to edit the file to leave only the lines you need, and don't leave all the commands active
- There must be no unmerged pull requests, or the deploy button will be deactivated
- No errors in the file or the deploy button will be deactivated.
4. Setup Git Version Control
Now go to git version control from your cPanel.
And give the same information about your git repository as shown below:
Enter your git repository URL :
Enter the desired path for the repository's directory. If you enter a way that does not exist, the system will automatically create the manual when it creates or clones the repository.
This name does not impact functionality but functions only as a display name.
If everything looks good, go ahead and click on "Create."
5. Manage Repositories
A list of all Git repositories currently connected to cPanel will appear. When you click Manage, you will be given a choice to Pull and deploy from the Git repository. Next, we will automate the process.
This tutorial has been tested on a private repository, and the result showed that it works.
About Raqib Nur
I discuss Web Tech & Productivity | I've developed 100+ websites, interacted with 37 founders, and worked with three startups. It's time for you to speak up; let's get started!