1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100 | ---
name: dgit-repo-management
description: Manage git repositories on a dgit host (create, push, configure, inspect, gc, delete, list). Use when an agent needs to set up or administer repositories served by dgit / durable-git, whether through the dgit-repo CLI or the raw HTTP admin endpoints.
---
# Managing repositories on a dgit host
dgit is a git server where each repository is a Cloudflare Durable Object.
Key behaviors that differ from GitHub-style hosts:
- **Push-to-create.** Pushing to a name that does not exist creates the
repository — and it is **public** on arrival.
- **Private-by-default requires pre-registration.** To keep a repository
private from the first push, register it with `private: true` before
pushing (`dgit-repo create`, or a `PUT /<repo>/config`).
- **Reads of public repositories are open.** Pushes, admin operations, and
everything on a private repository require the token.
## Setup
The host and credentials come from the environment, not flags:
1. Host: `$DGIT_HOST`, else `git config --global dgit.host <host>`.
2. Auth: a git credential helper must hold the token for
`https://<host>` (username is arbitrary; the password is the
`GIT_TOKEN`). Both `git push` and `dgit-repo` resolve credentials the
same way, via `git credential fill`.
If neither is configured, report the blocker to the user — do not guess
hosts or tokens.
## Preferred: the dgit-repo CLI
`scripts/dgit-repo` in this repository wraps every admin endpoint. It
needs `bash`, `curl`, `jq`, and `git`.
```sh
scripts/dgit-repo create NAME [--public] [-d DESC] [-s SECTION] [-o OWNER]
scripts/dgit-repo config NAME [--private|--public] [-d DESC] [-s SECTION] [-o OWNER]
scripts/dgit-repo show NAME
scripts/dgit-repo gc NAME
scripts/dgit-repo delete NAME [--yes]
scripts/dgit-repo list
```
Safety rails worth knowing (they surface as errors, not prompts):
- `create` refuses a name that already exists; it cannot silently flip an
existing repository private-to-public or back.
- `config` refuses a name that does not exist, so a typo cannot create a
stray repository.
- `delete` asks to type the repository name unless `--yes` is passed.
Deletion is irreversible — never add `--yes` without an explicit user
request to delete.
## Typical workflows
New private repository, then first push:
```sh
dgit-repo create myrepo -d "One-line description" -s tools
git remote add origin https://<host>/myrepo.git
git push -u origin main
```
New public repository: same, plus `--public`.
Publish an already-pushed repository (it was created public by a push):
```sh
dgit-repo config myrepo --private # or --public, -d, -s, -o
```
## Raw HTTP fallback
Without the CLI, the same operations are plain authenticated HTTP
(-u x:$GIT_TOKEN; config bodies are JSON):
```sh
curl -X PUT -u x:$GIT_TOKEN -H 'content-type: application/json' \
-d '{"description":"...","section":"tools","private":true}' \
https://<host>/myrepo/config
curl -X POST -u x:$GIT_TOKEN https://<host>/myrepo/gc
curl -X DELETE -u x:$GIT_TOKEN https://<host>/myrepo
curl -s https://<host>/api/repos # public index (no auth)
```
The JSON content API (`/<repo>/api/refs|log|commit|tree|blob|diff`) is
read-only and gated like the repository's pages; see `docs/api.md`.
## Gotchas
- A name must match `[A-Za-z0-9][A-Za-z0-9._-]*`; `api`, `info`, and a
few protocol paths are reserved.
- Failed authentications are rate-limited per IP (10 failures per
minute): after several 401s, wait instead of retrying in a loop.
- Unreachable objects are pruned automatically after forced updates and
ref deletions; `gc` is only needed manually after large rewrites.
- Repository metadata changes can lag a few seconds in per-isolate
caches; do not treat a stale index listing as a failed update.
|