This guide explains how to use Git on your HOSTDOG hosting via SSH. You will learn how to initialize a repository on the server, push code from your local machine, and set up a basic deployment workflow to keep your website in sync with your Git repository.
What you will need
- An active HOSTDOG hosting account with SSH access
- Git installed on your local machine (download Git)
- Basic familiarity with Git commands and the terminal
Option 1: Clone and push to a remote repository
The simplest approach is to use a hosted Git service (GitHub, GitLab, Bitbucket) and pull updates to your hosting account.
Connect to your hosting via SSH and navigate to the directory where you want your site files:
cd ~/public_html
Clone your Git repository into the current directory:
git clone https://github.com/yourusername/yourrepo.git .
The trailing dot (.) clones the files directly into the current directory rather than creating a subdirectory.
Whenever you push changes to your remote repository, connect via SSH and pull the latest version:
cd ~/public_html && git pull origin main
Option 2: Set up a bare repository on the server
For a more automated workflow, create a bare Git repository on your hosting account and push directly to it from your local machine. This lets you set up a post-receive hook for automatic deployment.
Connect via SSH and create a bare Git repository outside your public directory:
mkdir -p ~/repos/mysite.git
cd ~/repos/mysite.git
git init --bare
This hook automatically copies the latest code to your website directory after each push:
cat > ~/repos/mysite.git/hooks/post-receive << 'EOF'
#!/bin/bash
GIT_WORK_TREE=$HOME/public_html git checkout -f
EOF
chmod +x ~/repos/mysite.git/hooks/post-receive
On your local machine, add the server as a Git remote:
git remote add production yourusername@yourdomain.com:repos/mysite.git
Now deploy with a single command:
git push production main
Each push triggers the post-receive hook, which updates public_html automatically.
Git version control with your control panel
Your control panel also includes a Git Version Control tool (under Files) that provides a web interface for managing repositories. You can create repositories, clone from remote URLs, and pull updates without using the command line. This is convenient if you prefer a graphical interface.
Troubleshooting
Verify that SSH access is enabled and that you can connect via SSH normally. Check that your SSH key is correctly installed, or that you are prompted for a password. Also confirm the remote URL path is correct — it should match the full path to the bare repository (e.g., repos/mysite.git, not the absolute path).
Ensure the hook file is executable (chmod +x). Check that GIT_WORK_TREE points to the correct directory (e.g., $HOME/public_html). You can test the hook manually via SSH by running cd ~/repos/mysite.git && bash hooks/post-receive and checking for errors.