Overview
The receive-pack endpoint implements the Git Smart HTTP protocol for push operations. When you rungit push gost main, this endpoint receives your commits, anonymizes all metadata, and creates a pull request on your behalf.
Endpoints
Discovery: Get References
GitHub repository owner (user or organization)
Repository name
Must be
git-receive-packResponse
application/x-git-receive-pack-advertisementinternal/http/handlers.go:79-128
Data Transfer: Push Commits
GitHub repository owner
Repository name
Request Headers
application/x-git-receive-pack-requestGit clients typically send
100-continue for large pushesRequest Body
Binary Git packfile in pkt-line format:-
Command Section: Reference updates
-
Push Options (optional):
-
Packfile: Binary pack data starting with
PACK
Response
application/x-git-receive-pack-resultProtocol responses:
unpack ok, ok refs/heads/mainProgress messages shown to user
Error messages
internal/http/handlers.go:130-407
Processing Flow
When you push commits, gitGost performs the following operations:1. Request Validation
2. Packfile Processing
Clone Repository
gitGost clones the target repository from GitHub to establish the object databaseSource:
internal/git/receive.go:153-159Extract Packfile
Parse the pkt-line protocol to extract:Source:
- Reference updates (old SHA → new SHA)
- Push options (e.g.,
pr-hash) - Binary packfile data
internal/git/receive.go:184Unpack Objects
Import objects from packfile into the repository:Source:
internal/git/receive.go:205-224Anonymize Commits
Rewrite commit metadata to remove all identifying information:
- Author:
@gitgost-anonymous <[email protected]> - Committer:
@gitgost-anonymous <[email protected]> - Timestamp: Current server time
- Preserve: Commit message, tree, parents
internal/git/receive.go:252-258, internal/git/receive.go:262-3043. GitHub Integration
Fork Repository
Create a fork under the gitGost bot accountReturns the fork owner name (e.g.,
gitgost-bot)Push to Fork
Push the anonymized commits to a uniquely-named branch:Branch name is deterministic based on repo and timestamp.
Push Options
Git 2.10+ allows sending custom options with push commands:pr-hash Option
Usage:- Check if branch
gitgost-a3f8c1d2exists in the fork - Force-push new commits to that branch
- Look for an open PR from that branch
- Update the PR (if open) or create a new one (if closed)
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
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: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
internal/http/handlers.go:665-704
Error Handling
All errors are returned via side-band channel 3:Common Errors
Push Rejected: Service Temporarily Suspended
Push Rejected: Service Temporarily Suspended
Cause: Panic mode is activeResolution: Wait 15 minutes or contact adminCode:
internal/http/handlers.go:142-156Push Rejected: Rate Limit Exceeded
Push Rejected: Rate Limit Exceeded
Cause: Too many PRs from your IPResolution: Wait up to 1 hourCode:
internal/http/handlers.go:161-172Unpack Error
Unpack Error
Cause: Invalid or corrupted packfileResolution: Ensure repository is not corrupted, try re-cloningCode:
internal/http/handlers.go:212-218Error Creating Fork
Error Creating Fork
Cause: GitHub API failure or repository doesn’t existResolution: Verify repository exists and is publicCode:
internal/http/handlers.go:225-233Error Creating PR
Error Creating PR
Cause: PR already exists or API failureResolution: Check if PR already exists for your changesCode:
internal/http/handlers.go:311-319Example: Full Push Flow
1. Add gitGost Remote
2. Make Changes
3. Push Anonymously
4. Subscribe to Updates
Visithttps://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
Related Resources
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