Safe pull
AI 编程技能合集——让 Claude Code 听懂中文、帮你干活。基于 mattpocock/skills 改编并补充了原创工具。
npx -y skills add toRolex/rolex-skills --skill safe-pullAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 23 days oldThe repository was created 23 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Safe Git pull with rebase workflow — check remote changes, stash, rebase, restore, handle conflicts, and push. Covers main/develop sync and feature branch rebase. Use when the user says "sync", "pull latest", "拉取最新", "rebase main", "同步代码", "update branch", or wants to safely pull remote changes preserving linear history.
SKILL.md
2.5 KB, 791 tokens by cl100k_base, as published. Nobody here has run it
Safe Pull
安全拉取远程代码,使用 rebase 保持线性历史,自动暂存/恢复本地修改。
核心流程
# 1. 先看远程改了什么
git fetch && git log -p main..origin/main
# 2. 暂存本地修改
git stash
# 3. 用 rebase 而不是 merge(保持线性历史)
git pull --rebase
# 4. 恢复本地修改
git stash pop
完整流程
1. 检查远程变更
git fetch origin
git log --oneline <current-branch>..origin/<current-branch>
本地已是最新则直接结束。
2. 暂存本地修改
git status --short
git stash push -u -m "safe-pull: auto stash before rebase"
工作区干净则跳过。暂存失败则中止,报告原因。
3. Rebase 拉取
git pull --rebase origin <branch>
冲突时进入冲突处理子流程。网络失败重试一次,仍失败则中止。
4. 恢复本地修改
git stash pop
stash pop 冲突 → 保留 stash,列出冲突文件。空 stash → 跳过。
5. 推送(可选)
询问是否需要 git push 或 git push --force-with-lease。
冲突处理
git diff --name-only --diff-filter=U列出冲突文件- 告知用户冲突内容,不自动解决
- 用户解决后:
git rebase --continue - 用户确认放弃:
git rebase --abort && git stash pop
回滚
git rebase --abort 2>/dev/null
git stash list | grep "safe-pull:" && git stash pop
规则
- 禁止
--no-verify、--no-gpg-sign,禁止git reset --hard在 dirty tree 时执行 - 禁止 对 main/master 执行
--forcepush - stash 用
-u包含 untracked 文件 - 操作前告知当前分支和目标分支
分支场景
| 场景 | 目标分支 | 流程 |
|---|---|---|
| 同步 main/develop | origin/main 或 origin/develop | 标准四步 |
| Feature 分支 rebase develop | origin/develop | 标准四步 + --force-with-lease push |
| 多分支同步 | 依次执行 | 每个分支独立走标准流程 |
完成标准
- 本地分支与远程同步,线性历史。
- 本地修改已恢复(或用户已知冲突待处理)。
- 如已推送,远程分支也已更新。
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.