Endpoint
Repository owner username or organization name
Repository name (with or without
.git suffix)Authentication
This endpoint always requires HTTP Basic Authentication. Anonymous pushes are not permitted.Request
Headers
Content type for receive-pack requests
HTTP Basic Authentication credentials
Body
The request body contains pkt-line encoded commands followed by a packfile:Command format
Each command specifies a reference update:Current object ID (SHA-1) of the reference, or
0000000000000000000000000000000000000000 for new refsNew object ID (SHA-1) to update the reference to, or
0000000000000000000000000000000000000000 to deleteFull reference name (e.g.,
refs/heads/main, refs/tags/v1.0.0)Capabilities
The first command line includes capability declarations:Client requests detailed status report for each ref update
Client supports deleting references
Request atomic transaction (all updates succeed or all fail)
Client will not send thin packs
Packfile
After the flush packet, the request includes a packfile containing new objects:Response
Success response
HTTP status code (200 for success)
application/x-git-receive-pack-resultPkt-line encoded status report
Failure response
If unpacking fails:unpack ok: Packfile was successfully unpackedunpack <error>: Packfile unpacking failedok <ref>: Reference update succeededng <ref> <error>: Reference update failed
Reference update types
Create reference
Create a new branch or tag:Update reference
Update an existing reference (must be fast-forward unless forced):Delete reference
Delete a branch or tag:Validation rules
The server validates each reference update:- Old OID match: The specified old OID must match the current reference value
- Fast-forward check: Updates must be fast-forward (descendant of current commit)
- Object existence: New OID must exist after unpacking
- Reference creation: Cannot create a reference that already exists
- Reference deletion: Cannot delete a non-existent reference
apps/web/src/git/service.ts:598 for the full validation logic.
Atomic transactions
When theatomic capability is requested:
- All reference updates are validated before any are applied
- If any update fails validation, all updates are rejected
- Server responds with failure status for all references
Examples
Push new branch
Update main branch
Delete branch
Implementation details
The receive-pack endpoint is implemented across several components:Route handler
apps/web/src/routes/$owner/$repo/git-receive-pack.ts:5
Handles authentication and forwards requests to the Durable Object:
Durable Object handler
apps/web/src/do/repo.ts:95
Processes the request within the repository Durable Object:
Protocol implementation
apps/web/src/do/repo.ts:128
Handles packfile and reference updates:
Core protocol functions
The protocol implementation uses these key functions:parseReceivePackRequest(): Extract commands, capabilities, and packfile (apps/web/src/git/protocol.ts:90)buildReportStatus(): Build status report response (apps/web/src/git/protocol.ts:139)
Git operations
apps/web/src/git/service.ts
Provides Git operations using isomorphic-git:
indexPack(): Index packfile and add objects to repository (service.ts:204)applyRefUpdates(): Validate and apply reference updates (service.ts:598)
Command structure
apps/web/src/git/protocol.ts:84
Commands are parsed into this structure:
Result structure
apps/web/src/git/service.ts:7
Each reference update produces a result:
Error responses
Unauthorized access
Packfile unpack failure
Reference update failures
Atomic transaction failure
Common error reasons
old OID mismatch: The reference has been updated by another pushref already exists: Attempted to create an existing referenceref doesn't exist: Attempted to update or delete a non-existent referencenon-fast-forward update rejected: Update is not a descendant of current commitatomic transaction failed: One or more updates in atomic transaction failedunpack failed: Packfile could not be parsed or indexed
Related endpoints
Git Protocol Overview
Learn about the Git Smart HTTP Protocol implementation
git-upload-pack
Fetch and pull operations endpoint