5 min read Mar 1, 2026

How to Deploy Websites Using Git

Git deployment lets you automatically update your website or application by pushing changes from a Git repository (like GitHub, GitLab or Bitbucket) to…

FimuroHost Team

FimuroHost Team

Technical Writer

Share Article

Git deployment lets you automatically update your website or application by pushing changes from a Git repository (like GitHub, GitLab or Bitbucket) to your hosting server. This makes development faster, safer, and more organized — especially when working with teams or managing frequent updates.

In this guide, you’ll learn how Git deployment works and how to set it up step by step.


What Is Git Deployment?

Git deployment is a method of delivering your code from a Git repository to your hosting server. Instead of uploading files manually via FTP, you connect your repository to your hosting environment so that:

✔ Updates happen automatically
✔ Version control stays clean
✔ Rolling back is easy
✔ Deployment is repeatable and trackable

This workflow is especially useful for developers and teams.


How Git Deployment Works

Here’s the typical deployment flow:

  1. You push code to a branch (e.g., main or master)

  2. The hosting server detects the new commit

  3. The server pulls the latest version from the repository

  4. Your website or app updates with the newest code

Depending on your setup, this can be manual (pull on demand) or automatic (triggered on push).


Requirements Before You Start

Before you can use Git deployment, make sure you have:

✔ An active hosting account
✔ A Git repository (GitHub, GitLab, Bitbucket, etc.)
✔ SSH access to your hosting account
✔ Git enabled on the hosting server

You might also need a deployment key or SSH key for secure connection between the host and your repository.


Step-by-Step: Git Deployment Setup

Here’s how to set up Git deployment on your hosting account:


Step 1 — Prepare Your Repository

Make sure your project is in a Git repository. If it isn’t yet:

  1. Go to your local project folder

  2. Initialize Git:

git init
  1. Add files:

git add .
  1. Commit changes:

git commit -m "Initial commit"
  1. Push to remote repository:

git push origin main

Replace main with your preferred branch name.


Step 2 — Create SSH Key (Optional but Recommended)

If your repository requires authentication, generate an SSH key on your hosting server:

ssh-keygen -t rsa -b 4096

Copy the public key and add it to your repository’s deploy keys (for GitHub, GitLab, etc.).

This allows the server to pull code securely without using a password.


Step 3 — Connect to Hosting via SSH

Use SSH to log in to your hosting account:

ssh username@yourserverhostname

Replace username and yourserverhostname with your actual credentials.


Step 4 — Clone the Repository

Navigate to the directory where your website files should live:

cd public_html

Then clone the repository:

git clone [email protected]:username/repo.git .

This pulls your project into the server’s web root.


Step 5 — Set Up Deployment Branch

If you want to deploy from a specific branch (e.g., production):

git checkout production

Now your project will follow the selected branch.


Step 6 — Pull Updates

Each time you make changes, update the live site with:

git pull origin main

Replace main with your deployment branch.

For fully automatic deployment, you can configure webhooks in your Git repository to trigger pulls on push events.


Using Webhooks for Automatic Deployment

Some Git hosting services let you add webhooks that notify your server when new code is pushed.

To set this up:

  1. Go to your repository’s settings

  2. Find Webhooks

  3. Add your server’s deployment script URL

  4. Configure trigger events (e.g., push)

  5. Save

This way, code deployment becomes automatic.


Common Git Deployment Commands

Here are some useful Git commands for deployment:

Command

Purpose

git pull origin main

Pull latest changes

git status

View current branch status

git log

Show commit history

git checkout branchname

Switch branches


Best Practices

✔ Use a branch specifically for deployment

✔ Keep backups before deploying major changes

✔ Test changes on a staging environment first

✔ Use webhooks for smoother automation

✔ Secure deployment keys and SSH access

Following best practices makes your workflow reliable and safer.


Troubleshooting Common Issues

⚠ Permission Denied

If Git cannot pull due to permission errors:

✔ Make sure deployment SSH key is added to your repository

✔ Ensure correct file permissions on the server

✔ Confirm that your hosting plan supports Git


⚠ Merge Conflicts

If changes conflict:

✔ Resolve locally in your Git client

✔ Commit corrected code

✔ Push again


⚠ Wrong Branch Deployed

✔ Ensure you’re on the correct branch

✔ Use git branch to check current branch

✔ Switch with git checkout branchname


For Support

For any questions or technical assistance, contact our 24/7 support through Live Chat, support tickets, or our official social media pages.


Frequently Asked Questions

Q1. What is Git deployment?

Git deployment refers to updating your live website or application directly from a Git repository like GitHub or GitLab.


Q2. Do I need SSH access for Git deployment?

Yes — SSH is usually required to allow your hosting server to pull code securely from your repository.


Q3. Can I deploy automatically?

Yes — by configuring webhooks in your repository, you can trigger automatic pulls when changes are pushed.


Q4. What happens if deployment fails?

Check SSH authentication, branch settings, and permissions. Always backup before deploying major changes.


Q5. Is Git deployment suitable for beginners?

Yes — basic Git deployment is beginner-friendly, but advanced setups (like webhooks) may require some familiarity with Git and SSH.

FimuroHost Team

Written by

FimuroHost Team

Technical Writer