First check at cPanel SSH Access there should not be any key if there is any delete this than generate new key from terminal ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa
After generating key Go to .ssh directory and open .pub file and copy SSH Key Add this SSH Key into GITHUB REPO - Setting - Deploy Keys
Backup all files from public_html to _backup directory e.g. /home/_backup Open Git Version Control and Copy SSH GIT URL and Update Repository Directory path should /public_html Move Backup files into public_html
After moving files to go public_html/.git/hooks/post-receive
Update the following code make sure use your branch name e.g. master or main and edit /home/username/public_html or /home1/username/public_html
#!/bin/sh GIT_WORK_TREE=/home/username/public_html git checkout -f master cd /home/username/public_html
git pull origin master
composer install --no-dev --optimize-autoloader
php artisan migrate --force php artisan optimize:clear
Open Terminal again and check git connection
ssh -T git@github.com If success message appears means you are connected git repo via ssh connection
Than type cd public_html/.git/hooks chmod +x post-receive
Update cron job cd /home/username/public_html && git pull origin master