`git-http-backend` is a Node.js library designed to facilitate serving Git repositories over HTTP, providing a programmatic interface to the underlying Git protocol. It enables developers to construct custom HTTP Git servers, allowing them to either integrate their own `git-receive-pack` and `git-upload-pack` implementations or to delegate these operations to the system's installed Git executables. The package abstracts the complexities of the Git HTTP protocol, primarily by streaming request and response data. As of the provided metadata, the current stable version is 1.1.2. Its release cadence appears to be infrequent, reflecting its role as a focused utility. A key differentiator is its minimalist design, which offers core protocol parsing and streaming capabilities without imposing a complete server framework, thus allowing for flexible integration into existing Node.js HTTP server applications.
npm install git-http-backendVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to set up a basic HTTP server using `git-http-backend` to serve Git repositories, including handling gzipped requests and spawning system Git commands for push and pull operations.
Ensure robust input validation and sanitization for all request parameters, especially if `git` command arguments are derived from user input. Consider implementing a whitelist for allowed commands and arguments.
Implement authentication and authorization middleware in your HTTP server *before* piping requests to `git-http-backend` to secure access to repositories based on user permissions.
For ESM projects, use dynamic `import('git-http-backend')` or ensure your build setup correctly handles CommonJS modules. The simplest fix for hybrid projects is to stick to `require()` or use a transpiler.Extend the request stream handling to detect and decompress other `Content-Encoding` types using appropriate Node.js `zlib` methods (e.g., `createInflateRaw()` for deflate, `createBrotliDecompress()` for brotli).
Run `npm install git-http-backend` or `yarn add git-http-backend` in your project directory.
Verify that the bare Git repository (`myrepo.git`) exists at the specified `dir` path on the server. Ensure the `req.url` parsing correctly extracts the repository name and maps it to a valid physical location.
Check server logs for more detailed `git-receive-pack` errors. Verify that the user running the Node.js server has write permissions to the repository directory and that there is sufficient disk space.
Ensure `req.url` is correctly structured for Git HTTP requests (e.g., `/repo.git/info/refs?service=git-upload-pack`) and that the incoming request body (if any) is valid. Debug the `backend(req.url, cb)` call to inspect the `err` object.
No dependency data recorded yet.