Loading
Category:Technical


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.
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.
Go to your git repository settings --> Deploy key --> add deploy keys --> and paste the copied content. And then, run the below command.
If it returns this Hi **username/repository** You've successfully authenticated, but GitHub does not provide shell access. You're ready to go.
ssh -T git@github.com
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.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.
git@github.com:username/respository-name
This name does not impact functionality but functions only as a display name.
If everything looks good, go ahead and click on "Create."
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.

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!