Git

How to connect and use github with DirectAdmin git feature

How to connect git with DirectAdmin

Login into SSH and run the following command to create a new key pair

-ssh-keygen -t rsa -b 4096 -C “email@example.com”

When prompted for file location, press Enter to accept default (~/.ssh/id_rsa).
Set a passphrase or press Enter to skip it.

Add your SSH key to the SSH agent

eval “$(ssh-agent -s)”
ssh-add ~/.ssh/id_rsa

 

Show the public key:

cat ~/.ssh/id_rsa.pub

 

Copy the entire output.
Go to GitHub → Settings → SSH and GPG Keys → New SSH Key.
Paste the key and save.

Run the below command to secure SSH private key.

chmod 600 ~/.ssh/id_rsa

Run the following command in terminal to check connection of server with github account

ssh -T -i /home/sufiyans/newprivatekey git@github.com

OUTPUT
Hi Sufiyanshaikh123! You’ve successfully authenticated, but GitHub does not provide shell access.

 

CLONE REPOSITORY

GIT_SSH_COMMAND=’ssh -i /home/sufiyans/newprivatekey’ git clone git@github.com:Sufiyanshaikh123/whmcshooks.git

 

Clone into current directory without creating new folder

GIT_SSH_COMMAND=’ssh -i /home/sufiyans/newprivatekey’ git clone git@github.com:Sufiyanshaikh123/whmcshooks.git .

 

Pull sync only the new changes in the repo. If you have deleted any file intentionally, it won’t download it from repo again.

GIT_SSH_COMMAND=’ssh -i /home/sufiyans/newprivatekey’ git pull

 

Pull again from repo and also restore the deleted file.

GIT_SSH_COMMAND=’ssh -i /home/sufiyans/newprivatekey’ git fetch origin


The below command will:
Fetch the latest changes from GitHub.
Force your working directory to match the remote exactly.
Erase any uncommitted local changes or deletions.

git reset –hard origin/main

 

Sufiyan Shaikh

Recent Posts

CyberPanel Server Error (500)

Server Error (500) when trying to access the Cyberpanel If you are getting this error while accessing the cyberpanel, there…

1 year ago

How to host next js app on cpanel

How to host next js app in cpanel Login > Setup Node.js App > Create Application Enter the values shown…

1 year ago

WHMCS Development environment set

Update via PHPMYADMIN: Disable Captcha : UPDATE tblconfiguration SET value = '' WHERE setting = 'CaptchaSetting'; Update WHMCS link: UPDATE…

1 year ago

Lagom WHMCS notification hide pages list

3dsecure Access Denied Affiliates Affiliates Signup Announcements Banned Configure Products Downloads Downloads Denied Error Login Logout Password Reset Ticket Feedback…

1 year ago

Export/Import database via command line(ssh)

Export Database via SSH mysqldump --routines -u databaseusername -p databasename > database.sql   Import Database via SSH mysql -u databaseusername…

1 year ago

Correct File permissions for WordPress

If you are facing issue with file permissions, run this command within the public_html to fix the permissions issue find…

2 years ago