safe-pull
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.
- License 许可
- MIT
- 最近更新
- 2026-11-03
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- safe-pull
- description
- 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.
03 SKILL.md 正文
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 |
| 多分支同步 | 依次执行 | 每个分支独立走标准流程 |
完成标准
- 本地分支与远程同步,线性历史。
- 本地修改已恢复(或用户已知冲突待处理)。
- 如已推送,远程分支也已更新。
04 同仓库更多 Skills
writing-great-skills
Reference for writing and editing skills well — the vocabulary and principles that make a skill predictable.
writing-for-agents
覆盖创建、修改与审核 agent 指令规则、路由及指针文档(如 skill、AGENTS.md、CLAUDE.md)。
wait-what
停下。上一条消息没有说清楚:重新讲一遍。
to-questionnaire
把一个你无法完全回答的决策,变成一个让其他人填写的问题单。
teach-me
在教学工作区内教授用户一项新技能或概念。
handoff
将当前对话压缩为 handoff 文档,供另一个 agent 接续。