diff --git a/git-sync/SKILL.md b/git-sync/SKILL.md index 633dd6c..0d10ace 100644 --- a/git-sync/SKILL.md +++ b/git-sync/SKILL.md @@ -4,7 +4,7 @@ description: Use when 用户说"对xxx目录做一次 git 同步/提交推送/ category: custom metadata: author: Hermes Agent - last_updated: "2026-09-14" + last_updated: "2026-09-15" --- # Git Sync — 指定仓库一键同步 @@ -76,4 +76,7 @@ metadata: - `resolve remote`(`git reset --hard`)与 `resolve local`(force push)都会丢内容,必须先经 clarify 拿到用户明确选择,脚本侧再加 `GIT_SYNC_CONFIRM=yes` - push 失败(码 3)通常是 pull 后又有人推了东西:重新 `status`,再走分叉决策 - **`pull.rebase=true` 的仓库**(本机 nexus 即如此):有未暂存改动时 ff-only pull 必失败报 "cannot pull with rebase",哪怕与远端无文件重叠——先用 `git diff --name-only HEAD origin/main` 确认无重叠,再 `git -c pull.rebase=false pull --ff-only`,不必惊动用户。脚本遇此会自动打印 hint +- **push 报 `could not read Username for 'http://'`**:远端是 HTTP 且本机无该 host 凭据(keychain 里存的端口对不上也照样失败)。同主机若跑了 Gitea SSH,改 `git remote set-url origin ssh://git@:2222//.git` 即可直推;改前先 `git ls-remote ` 验证有权限,改后 `git push` 并用 `git ls-remote origin refs/heads/main` 核对远端 hash +- **`add -A` 会把未跟踪的大目录一并提交**(实测 node_modules 56MB / 5606 文件):`status` 里出现这类目录时先补 `.gitignore`(`node_modules/`、`.DS_Store`)再 sync,否则仓库历史被永久撑大 +- **生成物目录会被 `add -A` 一并提交**(实测 nexus 的 `sreweekly/translation_tasks/`:767 个 `task_XXXX.txt`/`meta.json` 流水线中间产物,且流水线跑完会自己删掉这批文件,导致「先提交、后全量删除」两个巨量提交):同步前先判断 status 里的新目录是成果还是中间产物,后者不要入库 - 脚本由其他技能/agent 复用时同样适用,别只当本技能专用 \ No newline at end of file