Files
soul-yongping/.cursor/scripts/README-gitea-sync.md

160 lines
5.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 与 Gitea192.168.1.201)同步
## 远程
- **gitea-local**`http://192.168.1.201:3000/fnvtk/soul-yongping.git`(拉取 + 推送)
## 手动同步
```bash
./.cursor/scripts/gitea-sync.sh
```
## 每 10 分钟自动同步macOS launchd
- 已安装:`~/Library/LaunchAgents/com.soul.yongping.gitea-sync.plist`
- 每 10 分钟执行一次,登录后自动加载
**启用:**
```bash
launchctl load ~/Library/LaunchAgents/com.soul.yongping.gitea-sync.plist
```
**停用:**
```bash
launchctl unload ~/Library/LaunchAgents/com.soul.yongping.gitea-sync.plist
```
**查看是否在跑:**
```bash
launchctl list | grep com.soul.yongping.gitea-sync
```
## 认证192.168.1.201 需登录时)
若 push/pull 需要账号密码,定时任务无法弹窗,请把凭证写进 remote URL勿提交到仓库
```bash
git remote set-url gitea-local 'http://用户名:token或密码@192.168.1.201:3000/fnvtk/soul-yongping.git'
```
或用系统钥匙串:
```bash
git config --global credential.helper osxkeychain
# 然后手动执行一次 gitea-sync.sh输入一次账号密码之后由钥匙串记住
```
## 日志
- 脚本内部:`.cursor/scripts/gitea-sync.log`
- launchd 标准输出:`.cursor/scripts/gitea-sync-launchd.log`
- launchd 错误:`.cursor/scripts/gitea-sync-launchd.err.log`
## 跨网克隆失败502 / `RPC failed` / `curl 18` / `early EOF`
现象:`git clone http://open.quwanzhi.com:3000/...` 枚举对象到 100% 后断线,或一开始就 **502 Bad Gateway**。仓库约 2.5 万对象时较常见,**根因多在服务端反代或链路**,客户端可做降级与重试。
### 1. 优先:浅克隆 + 按需补历史Windows `cmd` 示例)
先少传数据,成功率最高:
```bat
git config --global http.postBuffer 524288000
git clone --depth 1 --single-branch --branch devlop http://open.quwanzhi.com:3000/fnvtk/soul-yongping.git
cd soul-yongping
git fetch --unshallow
```
仍断线可再试 **partial clone**Git 2.22+
```bat
git clone --filter=blob:none --depth 1 --single-branch --branch devlop http://open.quwanzhi.com:3000/fnvtk/soul-yongping.git
```
失败目录可删后重试;或进入半成品目录执行 `git fetch` 多次Git 会续传。
### 2. 客户端其它设置(可选)
```bat
git config --global http.version HTTP/1.1
git config --global core.compression 0
```
压缩关掉会多占带宽,有时能避开中间设备对「大块压缩流」的处理问题。
### 3. 能走内网时改用局域网 Gitea
文档顶部 **gitea-local**`192.168.1.201:3000`)通常比公网 `:3000` 稳定;在公司/VPN 内优先用内网地址克隆。
### 3.1 内网 `192.168.1.201:3000` 仍 502 / early EOF
说明:**内网和公网同一症状 = 问题在 Gitea 本机或前面的反代**,不是「你电脑网络」 alone。
**先确认服务是否活着(在能访问内网的机器上):**
```bat
curl -sI http://192.168.1.201:3000/
```
-**立刻 502**:多为 **Nginx或宝塔反代连不上 Gitea 进程**Gitea 挂了、监听端口不对、防火墙)。
-**Web 能开、只有 git clone 断**:多为 **反代超时 / 缓冲** 不适合大块 `git-upload-pack` 流。
**有服务器权限时(宝塔 / Nginx**:在 **指向 Gitea 的那一段** 加大超时、关掉对 Git 流的缓冲(上游端口以你机器为准,常见 Gitea 在 `127.0.0.1:3000` 或其它端口,勿照抄错):
```nginx
client_max_body_size 512M;
proxy_connect_timeout 300s;
proxy_send_timeout 3600s;
proxy_read_timeout 3600s;
proxy_buffering off;
proxy_request_buffering off;
```
改完后 **`nginx -t && nginx -s reload`**,并 **重启 Gitea**。仍 502 时看 **`error.log`** 里 `upstream timed out` / `connection refused` 对应哪一层。
**若短期无法改服务器**:用下面 **离线 bundle**,从已有完整仓库的机器拷一份到 Windows不经过 HTTP 大包传输)。
### 4. 离线绕过git bundle推荐不依赖 Gitea HTTP 稳定)
**Mac / 已能拉全仓库的机器**(本仓库根目录)执行:
```bash
chmod +x .cursor/scripts/create-offline-bundle.sh
.cursor/scripts/create-offline-bundle.sh devlop
```
会在仓库根生成 `soul-yongping-devlop.bundle`,拷到 Windows 后:
```bat
git clone E:\路径\soul-yongping-devlop.bundle soul-yongping
cd soul-yongping
git remote add origin http://192.168.1.201:3000/fnvtk/soul-yongping.git
git fetch origin
```
日常 `pull`/`push` 仍走 Gitea若 push 仍断,再与运维修反代。
### 5. Windows 一键重试克隆(仍依赖服务端正常)
将本仓库拷到 Windows 或只拷脚本后,在 `cmd` 中进入脚本目录:
```bat
set REPO=http://192.168.1.201:3000/fnvtk/soul-yongping.git
set BRANCH=devlop
clone-soul-yongping-windows.bat
```
(需登录时第一次会提示账号密码,或事先 `git config --global credential.helper manager` 并手动 `git ls-remote` 存凭证。)
### 6. 服务端(有权限时):反代与 Gitea摘要
502 / 传一半断线,除第 3.1 节参数外,还需保证 **Nginx `proxy_pass` 指向的 Gitea 进程在线**。官方反代说明:<https://docs.gitea.com/installation/reverse-proxies>
### 7. 安全提醒
勿在截图/聊天记录里长期暴露「用户名:密码@」完整 URL改用 **访问令牌** + 凭证管理器Windows`git config --global credential.helper manager`)。