跳到正文
Skillpedia
通用编程17k · #10793

squash-commits

它能做什么

这个技能把当前分支上的提交重新整理成少量有逻辑的提交。适合在分享工作之前希望历史记录更整洁的开发者。

适用场景

  • ✓当你的分支有很多细小或凌乱的提交,并且你希望历史记录更简洁时。
  • ✓当你希望在提交拉取请求之前,把相关修改归并为几个有意义的提交时。
  • ✓当你需要移除已从 main 合并到分支中的合并提交时。

技能链接

https://github.com/pipecat-ai/pipecat/blob/main/.claude/skills/squash-commits/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/pipecat-ai/pipecat/blob/main/.claude/skills/squash-commits/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我把分支上的提交整理成几个清晰的提交,并且不改动任何代码。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会先检查你的工作是否已保存,并为分支创建备份副本,然后重置提交,同时保留每一项修改。接着它会提出分组方案,并在提交前请你确认。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Reorganize the commits on the current branch into a small number of logical commits. Do NOT change any file content — only the commit structure changes.

Instructions

1. Safety check

git status --short

If there are uncommitted changes, stop and tell the user to commit or stash them first.

2. Inspect the branch

git log main..HEAD --oneline
git diff main..HEAD --name-only

List every file changed vs main and every commit on the branch (excluding merge commits from main).

3. Create a backup branch

git branch backup/<current-branch-name>

Tell the user the backup exists so they can recover if needed.

4. Soft-reset to main and unstage everything

git reset --soft main
git restore --staged .

All branch changes are now in the working tree, unstaged. No content has changed.

5. Plan the logical groups

Read the changed files and the original commit messages to understand what the work covers. Group related files into logical commits. Typical groups:

  • Core feature or fix (new source files + modified core files)
  • Secondary features or fixes (each as its own commit if distinct)
  • Refactoring or renames
  • Tests
  • Changelogs / docs

Use the changelog files (if any) as a strong hint — each changelog entry often maps to one commit.

Present the proposed grouping to the user and ask for confirmation before committing.

6. Commit in logical groups

For each group, stage only the relevant files and commit with a clear message following the project's conventions:

git add <file1> <file2> ...
git commit -m "..."

Use conventional commit prefixes if the project uses them (feat:, fix:, refactor:, test:, chore:).

7. Verify

git log main..HEAD --oneline
git diff main..HEAD --name-only
git status --short

Confirm:

  • Commit count is small and each message is meaningful
  • The set of changed files vs main is identical to before
  • Working tree is clean

8. Remind about force-push

The branch history has been rewritten. Tell the user they will need to git push --force-with-lease when they are ready to update the remote. Do NOT push automatically.

Rules

  • Never change file contents. If you find yourself editing a file, stop.
  • Never skip the backup branch step.
  • Never force-push without explicit user instruction.
  • If any step fails or the result looks wrong, tell the user and suggest restoring from the backup: git reset --hard backup/<branch-name>.
常见问题

这会改变我的代码吗?

不会。该技能只改变提交的排列方式,不改变任何文件的内容。

可以撤销吗?

可以。该技能会先创建备份分支,如有需要,你可以恢复到原来的提交。

需要我确认分组吗?

需要。智能体会展示拟定的提交分组,并在进行任何提交前请你批准。

详情

作者的原始描述

Reorganize messy branch commits into a small set of logical, meaningful commits without changing any content. Drops merge-from-main commits. Safe: creates a backup branch first.

repo: pipecat-ai/pipecat

热度

GitHub 星标
17k
排名
#10793
许可证
BSD-2-Clause
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能