GIT_TERMINAL_PROMPT=0 GIT_ASKPASS=/bin/true git -c credential.helper= clone --depth 1 https://gitea.jianfgit.xyz/jianf/MailUI4Agents.git → 成功,HEAD 就是最新提交。 这条当初是最像的一个假设(镜像项目一般靠存起来的凭据去拉上游),实测排除。
105 lines
4.7 KiB
Markdown
105 lines
4.7 KiB
Markdown
# gitcode 镜像仓:为什么它不会自己更新
|
||
|
||
**结论:gitcode 上的 `JianFeeeee/MailUI4Agents` 是「导入 / 镜像」项目,只能从 gitcode
|
||
网页上点一次「拉取」来更新。我们这边推不进去(服务端拒绝),也没有 API 能触发。**
|
||
|
||
用户(2026-09-14):「git@gitcode.com:JianFeeeee/MailUI4Agents.git 这个镜像仓怎么也没更新?」
|
||
|
||
## 它是什么
|
||
|
||
| | |
|
||
|---|---|
|
||
| 网页 | https://gitcode.com/JianFeeeee/MailUI4Agents |
|
||
| 类型 | 导入 / 镜像项目(`import_status=finished`) |
|
||
| 上游(`import_url`) | `https://gitea.jianfgit.xyz/jianf/MailUI4Agents.git` —— 就是**我们自己的 Gitea** |
|
||
| 公开性 | public(匿名可 clone) |
|
||
|
||
`import_url` 是从项目页的 Nuxt payload 里读出来的(页面上直接写着):
|
||
|
||
```bash
|
||
curl -s https://gitcode.com/JianFeeeee/MailUI4Agents \
|
||
| grep -o '"https:[^"]*\.git"' # → gitea.jianfgit.xyz/jianf/MailUI4Agents.git
|
||
```
|
||
|
||
## 为什么推不进去
|
||
|
||
两条路都试过,都是 gitcode 服务端拒绝:
|
||
|
||
```bash
|
||
git push --dry-run git@gitcode.com:JianFeeeee/MailUI4Agents.git main
|
||
# fatal: <CH.00905401> This operation is not allowed because the repository is an image repository.
|
||
|
||
git push --dry-run https://gitcode.com/JianFeeeee/MailUI4Agents.git main
|
||
# remote: <CH.00905403> ... 403
|
||
```
|
||
|
||
「image repository」是 gitcode 的**措辞**(中文那套就叫「镜像」),指的是它那边的
|
||
**镜像项目**类型,**不是**容器镜像(虽然这个项目的 `container_registry_enabled` 也是 true)。
|
||
镜像项目的语义是**单向**的:只从上游拉,不接受推送。
|
||
|
||
## 为什么没有自动同步
|
||
|
||
那个页面自己的文案就是答案(同样是 Nuxt payload 里的字面量):
|
||
|
||
- 「对于滞后的提交,你可以通过**拉取更新**从源项目获取最新的代码」
|
||
- 「使用**同步源项目**的一键操作,即可获取源项目的最新代码提交和更新。」
|
||
- 「拉取全部分支更新」
|
||
- 「同步源项目所有分支的最新代码可能导致当前提交的代码丢失,请确认是否继续?」
|
||
|
||
也就是这是**手动一键操作**,不是定时任务。API 侧也没有这个能力 —— 下面 6 种端点形状
|
||
全部 404(`Authorization: Bearer <~/.git-credentials 里的 token>`):
|
||
|
||
```
|
||
POST /api/v5/repos/{owner}/{repo}/mirror/pull
|
||
POST /api/v5/repos/{owner}/{repo}/import/pull
|
||
POST /api/v5/repos/{owner}/{repo}/sync_source
|
||
POST /api/v5/repos/{owner}/{repo}/pull
|
||
POST /api/v5/projects/{id}/mirror/pull
|
||
POST /api/v5/projects/{id}/import/pull
|
||
```
|
||
|
||
## 我们这边是好的(已实测,别再怀疑上游)
|
||
|
||
```bash
|
||
# ① 上游公网可达,且报的 HEAD 就是我们最新的提交
|
||
curl -s --resolve gitea.jianfgit.xyz:443:101.201.37.155 \
|
||
"https://gitea.jianfgit.xyz/jianf/MailUI4Agents.git/info/refs?service=git-upload-pack"
|
||
# → d78f19f…(等于本地 HEAD 与 origin/main)
|
||
|
||
# ② 公网 DNS 有记录(不是只在内网 DNS 里有)
|
||
curl -s -H 'accept: application/dns-json' \
|
||
"https://dns.alidns.com/resolve?name=gitea.jianfgit.xyz&type=A"
|
||
# → 101.201.37.155
|
||
|
||
# ③ 镜像仓落后了多少个提交
|
||
git ls-remote git@gitcode.com:JianFeeeee/MailUI4Agents.git
|
||
git rev-list --count <镜像的 sha>..HEAD
|
||
|
||
# ④ 匿名(不带任何凭据)就能完整克隆 —— 所以 gitcode 拉上游**不需要凭据**,
|
||
# “存着的凭据过期了”不是本条的原因(这条当初是最像的一个假设)
|
||
GIT_TERMINAL_PROMPT=0 GIT_ASKPASS=/bin/true git -c credential.helper= \
|
||
clone --depth 1 https://gitea.jianfgit.xyz/jianf/MailUI4Agents.git /tmp/anon-probe
|
||
# → 成功,HEAD 就是最新那个提交
|
||
```
|
||
|
||
即:**上游是最新的、公网能克隆、域名能解析**。镜像停在第 N 个提交上,纯粹是因为
|
||
gitcode 那边没有人去点「拉取」。
|
||
|
||
## 要让镜像更新
|
||
|
||
打开 https://gitcode.com/JianFeeeee/MailUI4Agents ,页面上会给出一键「拉取 / 同步源项目」
|
||
(对滞后的提交会主动提示),点它并确认即可。**需要以仓库所有者身份登录** —— 本机的
|
||
共享浏览器 profile(`/home/newqqagent/browser_profiles/shared`)里只有 gitcode 的匿名
|
||
Cookie(`_frid` / `uuid_tt_dd` / `Hm_lvt_*` 之类),没有登录态,所以这条动作没法由
|
||
agent 代点。
|
||
|
||
## 如果希望它别再掉队
|
||
|
||
镜像项目的单向语义决定了「推着它走」这条路是堵死的。想自动化只有换一种镜像方式:
|
||
|
||
1. 在 gitcode 上建一个**普通项目**(不是导入 / 镜像项目),然后由我们这边推
|
||
(本地 `git remote add` + 每次提交后推,或定时推)。这条路可自动化,代价是 URL 变了。
|
||
2. 保持现状:需要对外可见时,人工点一次「拉取」。
|
||
|
||
选 1 之前先问 —— 换 URL 是对外契约的变更。
|