Git - Dumb HTTP



Git dumb HTTP protocol is also known as the Legacy HTTP Protocol. It is the older and simpler method of serving the Git repositories over HTTP.

Git is treated like a collection of files, where the files are served statically.

Key Features

1. File-based System − In dumb HTTP, the files are served statically. The objects such as commits, blobs, trees, etc. are retrieved by downloading them one after the other from server.

2. Git-specific Logic Missing − No Git-specific services or commands are required on server. Any available web server, such as Apache can serve the git directory as a set of files.

3. Inefficient − As the server does not require any Git-specific commands, the user has to clone, pull, fetch, etc. one at a time. This makes the whole process considerably slow.

4. Smart Negotialtion Missing − Reduntant and unnecessary downloads of objects take place, as Dumb HTTP does not negotiate with client.

5. Read-Only − Dumb HTTP is read-only. It lets you clone, pull, and fetch from a repository, but you can not push anything to server

  • The web server serves the raw Git repository as files straight up in Dumb HTTP.

  • A bare Git repository must be installed beneath the HTTP document root in order to set up Dumb HTTP, and a post-update hook must be set up to handle repository updates.

  • After enabled, Dumb HTTP can be used to clone the repository by any user having access to the web server hosting it.

  • Though it lacks Smart HTTP's sophisticated features, Dumb HTTP makes Git operations over HTTP simpler and more accessible.

How It Works?

A series of HTTP requests are made, when you clone or fetch a repository:

  • Individual objects from the .git/objects/ directory.

  • Information about references (refs) from .git/refs.

  • Pack Files from .git/objects/pack.

As each object in dumb HTTP is considered and downloaded as a separate HTTP request, the overall performance is slow.

To enable read access to our Git repository over HTTP, follow these steps:

cd /var/www/htdocs/
git clone --bare /path/to/git_project gitproject.git
cd gitproject.git
mv hooks/post-update.sample hooks/post-update
chmod a+x hooks/post-update

Git's default post-update hook runs git update-server-info to keep HTTP fetching and cloning working properly.

  • This hook is automatically triggered when changes are pushed to a repository, including over SSH.

  • Once the repository has been pushed, other users can clone it by running commands like git clone http://example.com/path/to/repo.git.

  • By retrieving an entire copy of the repository, this command makes sure that all relevant metadata is current and available over HTTP.

Advertisements