Site.eu

How do I use Git?

3 min read

How do I use Git?

Is your website in Git? Then you can put it on your web hosting at Site.eu straight from GitHub, GitLab, Bitbucket or another Git provider. No uploading file by file. Git works over SSH, so you do it all from the command line.

Before you start

  • SSH is on for your web hosting, and you can log in with it. Here's how to turn on SSH and log in.
  • You know your hosting username and the server name. Open the Web hosting tab of your plan. Under Web hosting information, you'll find your Username. The server name is the address of Go to control panel, without "https://" and ":2222".

Step 1: Log in with SSH. Then make a key for your web hosting:

ssh-keygen -t ed25519

Press Enter to save the key in the usual place. Next, it asks for a passphrase. You can set one, but you don't have to. If you do, Git asks for it every time it connects.

Step 2: Show the public part of your key:

cat ~/.ssh/id_ed25519.pub

Copy the whole line. It starts with "ssh-ed25519".

Step 3: Add this key to your account at GitHub, GitLab, Bitbucket or another Git provider. You'll find the place for it in your account settings, under SSH keys. Paste the line and save it.

Put your website on your web hosting

Step 4: Go to the website folder of your domain name. Every domain name has its own: domains/yourdomain.com/public_html. Use your own domain name:

cd ~/domains/yourdomain.com/public_html

Step 5: Empty the folder. Git can only clone into an empty folder. And a new folder isn't empty: DirectAdmin puts a default index.html in it. See what's there:

ls -A

Delete what you don't need, like that default page:

rm index.html

Run ls -A again. No output? Then the folder is empty.

Step 6: Clone your repository. Use the SSH address of your own repository, from the Clone or Code button at your Git provider. Mind the dot at the end. It means "right here". Without it, Git makes an extra folder inside public_html.

git clone git@github.com:your-name/your-website.git .

The first time, SSH asks if you trust the server of your Git provider, for example github.com. Type yes and press Enter. You'll see the cloning progress right away.

Just want to try it first? Clone this tiny example repository from GitHub. It has just one file, and it lands in a new folder in your home folder, not on your website:

git clone git@github.com:octocat/Hello-World.git ~/hello-world

Update your website later

Pushed new changes to your repository? Log in with SSH, go to the same folder and type:

git pull

Good to know

Following an older guide? Many say to type plain ssh-keygen and then cat ~/.ssh/id_rsa.pub. On our newest servers, plain ssh-keygen makes an ed25519 key instead. Then id_rsa.pub doesn't exist, and you get "No such file or directory". With "-t ed25519", the steps above work on every server.

Need help? Contact us by WhatsApp, Telegram or email.

Couldn’t find what you were looking for?

You can always chat with one of our experts for any questions you might have!

New articles added