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 protected]

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 [email protected]

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 [email protected]:Sufiyanshaikh123/whmcshooks.git

 

Clone into current directory without creating new folder

GIT_SSH_COMMAND=’ssh -i /home/sufiyans/newprivatekey’ git clone [email protected]: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

 

Leave a Comment