Compare commits

...

2 Commits

View File

@@ -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,6 @@ 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://<host>'`**:远端是 HTTP 且本机无该 host 凭据(keychain 里存的端口对不上也照样失败)。同主机若跑了 Gitea SSH,改 `git remote set-url origin ssh://git@<host>:2222/<owner>/<repo>.git` 即可直推;改前先 `git ls-remote <ssh-url>` 验证有权限,改后 `git push` 并用 `git ls-remote origin refs/heads/main` 核对远端 hash
- **`add -A` 会把未跟踪的大目录一并提交**(实测 node_modules 56MB / 5606 文件):`status` 里出现这类目录时先补 `.gitignore`(`node_modules/`、`.DS_Store`)再 sync,否则仓库历史被永久撑大
- 脚本由其他技能/agent 复用时同样适用,别只当本技能专用