docs(scripts): Gitea 克隆 502 排查、Nginx 要点、离线 bundle 与 Windows 克隆批处理
Made-with: Cursor
This commit is contained in:
@@ -53,3 +53,107 @@ git config --global credential.helper osxkeychain
|
||||
- 脚本内部:`.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`)。
|
||||
|
||||
37
.cursor/scripts/clone-soul-yongping-windows.bat
Normal file
37
.cursor/scripts/clone-soul-yongping-windows.bat
Normal file
@@ -0,0 +1,37 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
REM 按需修改:内网或公网;账号密码勿长期写死,建议用访问令牌 + credential manager
|
||||
if not defined REPO set "REPO=http://192.168.1.201:3000/fnvtk/soul-yongping.git"
|
||||
if not defined BRANCH set "BRANCH=devlop"
|
||||
|
||||
git config --global http.postBuffer 524288000
|
||||
git config --global http.version HTTP/1.1
|
||||
|
||||
if exist soul-yongping (
|
||||
echo 目录 soul-yongping 已存在,请先改名或删除后再运行。
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [1/3] 浅克隆 --depth 1 ...
|
||||
git clone --depth 1 --single-branch --branch "%BRANCH%" "%REPO%" soul-yongping
|
||||
if !errorlevel! equ 0 goto unshallow
|
||||
|
||||
echo [2/3] 失败,尝试 partial clone ...
|
||||
git clone --filter=blob:none --depth 1 --single-branch --branch "%BRANCH%" "%REPO%" soul-yongping
|
||||
if !errorlevel! equ 0 goto unshallow
|
||||
|
||||
echo [3/3] 仍失败。502/early EOF 多为服务器 Nginx 超时或 Gitea 上游异常,见 README-gitea-sync.md「内网仍 502」与离线 bundle。
|
||||
exit /b 1
|
||||
|
||||
:unshallow
|
||||
cd soul-yongping
|
||||
echo 拉全历史 git fetch --unshallow ...
|
||||
git fetch --unshallow
|
||||
if !errorlevel! neq 0 (
|
||||
echo unshallow 未完成可多执行几次: git fetch --unshallow
|
||||
)
|
||||
cd ..
|
||||
echo 完成。
|
||||
exit /b 0
|
||||
12
.cursor/scripts/create-offline-bundle.sh
Executable file
12
.cursor/scripts/create-offline-bundle.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
# 在「已有完整仓库」的机器上生成 bundle,拷到 U 盘/共享盘后 Windows: git clone xxx.bundle soul-yongping
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
cd "$ROOT"
|
||||
BRANCH="${1:-devlop}"
|
||||
OUT="${2:-$ROOT/soul-yongping-${BRANCH}.bundle}"
|
||||
git rev-parse --verify "$BRANCH" >/dev/null
|
||||
git bundle create "$OUT" "$BRANCH"
|
||||
echo "已生成: $OUT"
|
||||
echo "Windows 示例: git clone %CD%\\soul-yongping-${BRANCH}.bundle soul-yongping"
|
||||
echo "后续补远程: cd soul-yongping && git remote add origin http://192.168.1.201:3000/fnvtk/soul-yongping.git"
|
||||
Reference in New Issue
Block a user