How this skill is triggered — by the user, by Claude, or both
Slash command
/git-tools:historyThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Git 历史管理技能 - 重写、优化和分析历史。
Git 历史管理技能 - 重写、优化和分析历史。
# 分析历史质量
/history analyze --depth 100
# Interactive rebase
/history rebase HEAD~10
# 搜索提交
/history search --author "john"
# 创建快照
/history snapshot pre-release
| 指标 | 说明 | 健康标准 |
|---|---|---|
| 提交频率 | 每日提交次数 | 稳定,无长期中断 |
| 提交粒度 | 每次提交的变更量 | 适中(<500行/次) |
| 信息质量 | 提交信息规范性 | 遵循 Conventional Commits |
| 原子性 | 提交的独立性 | 每个提交独立完整 |
git rebase -i <base>| 命令 | 说明 | 使用场景 |
|---|---|---|
| pick | 保留提交 | 默认操作 |
| reword | 修改提交信息 | 修正拼写错误 |
| squash | 合并到前一提交 | 压缩多个小提交 |
| fixup | 合并但丢弃信息 | 自动化压缩 |
| drop | 删除提交 | 移除无用提交 |
| edit | 暂停修改 | 分割提交 |
# 压缩最近 3 个提交
git rebase -i HEAD~3
# 将后两个改为 squash
# 修改历史提交信息
git rebase -i HEAD~5
# 将目标提交改为 reword
# 分割提交
git rebase -i HEAD~3
# 将目标提交改为 edit
# 然后 git reset HEAD~ && git add -p 分次提交
# 按作者搜索
git log --author="john"
# 按日期范围
git log --since="2024-01-01" --until="2024-01-31"
# 按提交信息
git log --grep="fix"
# 按文件变更
git log --follow -- path/to/file
# 按内容搜索
git log -S "function_name"
# 查找引入特定代码的提交
git log -p -S "deprecated_code" --all
# 查找空提交信息的提交
git log --oneline --no-merges | grep -E '^[a-f0-9]+ $'
# 查找大体积提交
git log --no-merges --format="%H %s" --stat | \
awk '/files? changed/ { if ($4 > 500) print }'
# 创建命名快照
git tag snapshot-pre-release-2024-01-15
# 创建分支快照
git branch backup/pre-refactor HEAD
# 使用 stash 保存工作区
git stash push -m "WIP: feature-in-progress"
# 恢复到标签
git reset --hard snapshot-pre-release-2024-01-15
# 恢复到分支
git reset --hard backup/pre-refactor
# 恢复 stash
git stash pop
{
"history": {
"autoAnalysis": true,
"rebaseSafety": true,
"snapshotRetention": 30,
"autoBackup": true
}
}
以下操作会重写历史,已推送到远程的提交需要谨慎操作:
git rebase -i 交互式变基git commit --amend 修改最后提交git filter-branch 历史重写git reset --hard 硬重置--dry-run 预览模式npx claudepluginhub protagonistss/ithinku-plugins --plugin git-toolsRewrites a feature branch's messy commit history into clean, conventional commits that tell a progressive, linear story. Handles backup, soft reset, and atomic recommit.
Rewrites Git branch history into clean, narrative-quality commits for code review. Creates backup branch, reimplements changes from main diff, verifies byte-identical, replaces original.
Investigates GitHub repository history before risky code changes using git blame/log, PRs, review comments, and rename/cherry-pick heuristics. Use before editing API, security, concurrency, or migration code.