Skip to main content

Overview

The receive-pack endpoint implements the Git Smart HTTP protocol for push operations. When you run git push gost main, this endpoint receives your commits, anonymizes all metadata, and creates a pull request on your behalf.

Endpoints

Discovery: Get References

Returns available references (branches, tags) and server capabilities.
string
required
GitHub repository owner (user or organization)
string
required
Repository name
string
required
Must be git-receive-pack

Response

string
application/x-git-receive-pack-advertisement
Example Response (pkt-line format):
Implementation: internal/http/handlers.go:79-128

Data Transfer: Push Commits

Receives a Git packfile containing commits, anonymizes them, and creates a pull request.
string
required
GitHub repository owner
string
required
Repository name

Request Headers

string
required
application/x-git-receive-pack-request
string
Git clients typically send 100-continue for large pushes

Request Body

Binary Git packfile in pkt-line format:
  1. Command Section: Reference updates
  2. Push Options (optional):
  3. Packfile: Binary pack data starting with PACK
Example Structure:

Response

string
application/x-git-receive-pack-result
The response uses the side-band-64k protocol with three channels:
protocol
Protocol responses: unpack ok, ok refs/heads/main
progress
Progress messages shown to user
error
Error messages
Success Response (decoded):
Implementation: internal/http/handlers.go:130-407

Processing Flow

When you push commits, gitGost performs the following operations:

1. Request Validation

2. Packfile Processing

1

Clone Repository

gitGost clones the target repository from GitHub to establish the object database
Source: internal/git/receive.go:153-159
2

Extract Packfile

Parse the pkt-line protocol to extract:
  • Reference updates (old SHA → new SHA)
  • Push options (e.g., pr-hash)
  • Binary packfile data
Source: internal/git/receive.go:184
3

Unpack Objects

Import objects from packfile into the repository:
Source: internal/git/receive.go:205-224
4

Anonymize Commits

Rewrite commit metadata to remove all identifying information:
  • Author: @gitgost-anonymous <anonymous@gitgost.local>
  • Committer: @gitgost-anonymous <anonymous@gitgost.local>
  • Timestamp: Current server time
  • Preserve: Commit message, tree, parents
Only new commits (not in origin/main) are rewritten.Source: internal/git/receive.go:252-258, internal/git/receive.go:262-304

3. GitHub Integration

1

Fork Repository

Create a fork under the gitGost bot account
Returns the fork owner name (e.g., gitgost-bot)
2

Push to Fork

Push the anonymized commits to a uniquely-named branch:
Branch name is deterministic based on repo and timestamp.
3

Create Pull Request

Open a PR from gitgost-bot:gitgost-a3f8c1d2 to owner:main
4

Notify User

Publish notification to ntfy topic:
User can subscribe (no account required) for PR updates.

Push Options

Git 2.10+ allows sending custom options with push commands:

pr-hash Option

Usage:
When provided, gitGost will:
  1. Check if branch gitgost-a3f8c1d2 exists in the fork
  2. Force-push new commits to that branch
  3. Look for an open PR from that branch
  4. Update the PR (if open) or create a new one (if closed)
Implementation: internal/http/handlers.go:242-292

Metadata Stripping

gitGost completely removes identifying information from commits:

Before Anonymization

After Anonymization

What’s preserved: Commit message, file changes, tree structureWhat’s removed: Author name, email, original timestamp, any PGP signatures
The anonymization process creates entirely new commit objects with new SHA hashes. Source: internal/git/receive.go:336-367

Rate Limiting

gitGost implements multiple layers of rate limiting:

Per-IP Rate Limit

When exceeded, the push is rejected with:
Implementation: internal/http/handlers.go:160-172

Global Burst Detection

Detects coordinated bot attacks: When triggered:
  • Admin receives ntfy alert
  • Admin can activate panic mode
  • Admin can rollback recent PRs
Implementation: internal/http/handlers.go:665-704

Error Handling

All errors are returned via side-band channel 3:

Common Errors

Cause: Panic mode is activeResolution: Wait 15 minutes or contact adminCode: internal/http/handlers.go:142-156
Cause: Too many PRs from your IPResolution: Wait up to 1 hourCode: internal/http/handlers.go:161-172
Cause: Invalid or corrupted packfileResolution: Ensure repository is not corrupted, try re-cloningCode: internal/http/handlers.go:212-218
Cause: GitHub API failure or repository doesn’t existResolution: Verify repository exists and is publicCode: internal/http/handlers.go:225-233
Cause: PR already exists or API failureResolution: Check if PR already exists for your changesCode: internal/http/handlers.go:311-319

Example: Full Push Flow

1. Add gitGost Remote

2. Make Changes

3. Push Anonymously

Client Output:

4. Subscribe to Updates

Visit https://ntfy.sh/gitgost-pr-a3f8c1d2 or use the ntfy app to receive notifications when:
  • PR is commented on
  • PR is merged
  • PR is closed

5. Update the PR

Git Smart HTTP

Learn about the protocol gitGost implements

Upload-Pack

Fetch operations (git pull/fetch)

Quickstart

Get started in 2 minutes

How It Works

Technical deep dive