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

5.3 KiB
Raw Blame History

与 Gitea192.168.1.201)同步

远程

  • gitea-localhttp://192.168.1.201:3000/fnvtk/soul-yongping.git(拉取 + 推送)

手动同步

./.cursor/scripts/gitea-sync.sh

每 10 分钟自动同步macOS launchd

  • 已安装:~/Library/LaunchAgents/com.soul.yongping.gitea-sync.plist
  • 每 10 分钟执行一次,登录后自动加载

启用:

launchctl load ~/Library/LaunchAgents/com.soul.yongping.gitea-sync.plist

停用:

launchctl unload ~/Library/LaunchAgents/com.soul.yongping.gitea-sync.plist

查看是否在跑:

launchctl list | grep com.soul.yongping.gitea-sync

认证192.168.1.201 需登录时)

若 push/pull 需要账号密码,定时任务无法弹窗,请把凭证写进 remote URL勿提交到仓库

git remote set-url gitea-local 'http://用户名:token或密码@192.168.1.201:3000/fnvtk/soul-yongping.git'

或用系统钥匙串:

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 示例)

先少传数据,成功率最高:

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 cloneGit 2.22+

git clone --filter=blob:none --depth 1 --single-branch --branch devlop http://open.quwanzhi.com:3000/fnvtk/soul-yongping.git

失败目录可删后重试;或进入半成品目录执行 git fetch 多次Git 会续传。

2. 客户端其它设置(可选)

git config --global http.version HTTP/1.1
git config --global core.compression 0

压缩关掉会多占带宽,有时能避开中间设备对「大块压缩流」的处理问题。

3. 能走内网时改用局域网 Gitea

文档顶部 gitea-local192.168.1.201:3000)通常比公网 :3000 稳定;在公司/VPN 内优先用内网地址克隆。

3.1 内网 192.168.1.201:3000 仍 502 / early EOF

说明:内网和公网同一症状 = 问题在 Gitea 本机或前面的反代,不是「你电脑网络」 alone。

先确认服务是否活着(在能访问内网的机器上):

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 或其它端口,勿照抄错):

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.logupstream timed out / connection refused 对应哪一层。

若短期无法改服务器:用下面 离线 bundle,从已有完整仓库的机器拷一份到 Windows不经过 HTTP 大包传输)。

4. 离线绕过git bundle推荐不依赖 Gitea HTTP 稳定)

Mac / 已能拉全仓库的机器(本仓库根目录)执行:

chmod +x .cursor/scripts/create-offline-bundle.sh
.cursor/scripts/create-offline-bundle.sh devlop

会在仓库根生成 soul-yongping-devlop.bundle,拷到 Windows 后:

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 中进入脚本目录:

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改用 访问令牌 + 凭证管理器Windowsgit config --global credential.helper manager)。