gitprotocol-http - Linux


Overview

The gitprotocol-http command is a wrapper script for Git’s builtin HTTP server. It allows users to serve local Git repositories over HTTP. This is useful for sharing code with collaborators who do not have direct access to the repository.

Syntax

gitprotocol --httpd-upload-pack=<path> --httpd-get-objects=<path> [args]

Options/Flags

  • –httpd-upload-pack (required): The path to the upload-pack program.
  • –httpd-get-objects (required): The path to the get-objects program.
  • –address (optional): The IP address or hostname to listen on.
  • –port (optional): The port number to listen on.
  • –auth-user-file (optional): The file containing the username and password pairs.
  • –ssl-cert-file (optional): The SSL certificate file.
  • –ssl-key-file (optional): The SSL key file.

Examples

To serve a local repository over HTTP on port 8080, run the following command:

gitprotocol --httpd-upload-pack=/usr/bin/git-upload-pack --httpd-get-objects=/usr/bin/git-get-objects --port=8080

To use HTTP authentication, create a file containing the username and password pairs, and specify the file using the --auth-user-file option.

gitprotocol --httpd-upload-pack=/usr/bin/git-upload-pack --httpd-get-objects=/usr/bin/git-get-objects --port=8080 --auth-user-file=/etc/git-http-users

Common Issues

If you encounter the error "protocol error: bad request", make sure that the --httpd-upload-pack and --httpd-get-objects options are set correctly.

Integration

The gitprotocol-http command can be integrated with other Linux commands to create custom workflows. For example, you can use the following command to serve a repository over HTTPS using a self-signed certificate:

openssl req -x509 -newkey rsa:4096 -nodes -days 365 -out cert.pem -keyout key.pem
gitprotocol --httpd-upload-pack=/usr/bin/git-upload-pack --httpd-get-objects=/usr/bin/git-get-objects --port=8080 --ssl-cert-file=cert.pem --ssl-key-file=key.pem

Related Commands

  • git
  • git-upload-pack
  • git-get-objects