CLI and APIs
Upload a large push in parts
Your push is too large for one request, and you write your own client. Send the pack in parts over REST: the forge puts them together, and lands them as one git push.
2 min read
src repo push does this for you: see Push a large repository. MCP has no upload, because a tool call cannot carry a pack.
You need:
- A full pack (not thin) of the push.
- Write access to the repository, with a token that is not a job token.
A path that starts with ... is under /repos/{owner}/{repo}. Only the caller that started an upload can send its parts, finish it or delete it.
1. Start the upload
Send POST .../git/uploads. It answers 201 with {"id", "partBytes", "maxObjects", "expiresAt"}.
- Every part but the last has
partBytesbytes. By default, that is the push request limit of the site less 1 MiB, never less than 5 MiB, and never more than 100 MiB, the most that one request to object storage carries. - For smaller parts, send the optional body
{"partBytes": 10485760}. - The pack can hold
maxObjectsobjects. - The upload lasts one hour, until
expiresAt(milliseconds since the epoch).
2. Send each part
Send PUT .../git/uploads/{id}/parts/{n} for part n, from 1, with a Content-Length. It answers {"n", "bytes"}.
A part over the limit gets 413.
3. Finish the upload
Send POST .../git/uploads/{id}/finish with the number of parts and the ref updates:
{"parts": 3, "updates": [{"ref": "refs/heads/main", "old": "<id or null>", "new": "<id>"}]}
It lands the pack as a git push, and answers {"refs": [{"ref", "ok", "error"}], "messages"}.
- All refs move, or none.
- A ref that is not at its
oldcommit gets409. - A pack that Source refuses gets
422with the reason, for example push protection. - If the git servers of the repository do not answer, the finish gets
503. The upload stays, so you can send the finish again later. - The finish spends the upload: a second finish gets
404.
Done
The pack is in the repository, and the refs moved, as after a git push.
Delete an upload
To stop an upload, send DELETE .../git/uploads/{id}. It answers 204, and deletes the parts.