无需交互式编辑器,程序化重排、拆分、删除或修订任意 Git 历史提交。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "non-interactive-git-rebase" 技能: 1. 下载 https://raw.githubusercontent.com/facebook/hermes/static_h/.claude/skills/non-interactive-git-rebase/SKILL.md 2. 保存为 ~/.claude/skills/non-interactive-git-rebase/SKILL.md 3. 装好后重载技能,告诉我可以用了
请给我一个无需交互式编辑器的 git rebase 方案:把最近 6 个提交中的第 2 个移到第 5 个后面,并将第 4、5 个提交压缩为一个,要求使用 GIT_SEQUENCE_EDITOR 或等效脚本,附完整命令和注意事项。
一套可执行的非交互式 rebase 命令,含提交顺序调整、压缩步骤及风险提示。
我需要拆分不是顶部的某个 Git 提交:把最近 8 个提交中的第 3 个拆成两个提交,其中一个只保留特定文件改动。请提供不依赖交互式编辑器的方法,包括自动选择 hunk 或按文件拆分的命令流程。
分步命令方案,展示如何定位目标提交、拆分内容并重新提交。
请告诉我如何在一个提交范围内,无需交互式编辑器,批量修订 Git 历史中某个提交的 author、commit message 和日期,并确保其他提交保持不变。请给出脚本化做法和验证方法。
可复用的脚本化修订方案,含元数据修改命令与结果校验方式。
git rebase -i normally opens an editor for the todo list. By setting GIT_SEQUENCE_EDITOR to a command that replaces the todo file with a pre-prepared one, you can perform any interactive rebase operation — reorder, drop, squash, edit, amend — entirely from scripts.
Before any rebase, create a backup branch:
git branch backup-before-rebase HEAD
After the rebase succeeds and verification passes, do NOT delete the backup branch automatically. Always ask the user before deleting it, unless the user explicitly requested automatic cleanup. The backup is cheap to keep and the user may discover problems later.
The editor receives the todo file path as $1. Any command that overwrites that file works:
# Replace the todo with our prepared version
GIT_SEQUENCE_EDITOR="cp /tmp/prepared-todo" git rebase -i <base>
Git generates the default todo (all pick lines), then invokes cp /tmp/prepared-todo <todo-file>, which replaces it with your version. Git then executes the rewritten todo.
Extract the default todo without actually rebasing — copy it out, then fail the editor so git aborts:
GIT_SEQUENCE_EDITOR='cp $1 /tmp/default-todo && false' git rebase -i <base>
The false exits non-zero, so git aborts the rebase. You have the todo file, no rebase happened.
Or build it directly from git log:
git rev-list --reverse <base>..HEAD | while read hash; do
echo "pick $hash $(git log --oneline -1 $hash | cut -d' ' -f2-)"
done > /tmp/prepared-todo
Then edit the file: reorder lines, change pick to drop/squash/edit/etc.
The --exec <cmd> flag inserts an exec <cmd> line after every pick in the todo. Combined with GIT_SEQUENCE_EDITOR=: (a no-op that succeeds, leaving the default todo unchanged), this runs a command after each commit is replayed — no editor needed.
Change author email on all commits in a range:
GIT_SEQUENCE_EDITOR=: git rebase -i <base> --exec \
'if [ "$(git log -1 --format=%ae)" != "[email protected]" ]; then git commit --amend --no-edit --author="Name <[email protected]>"; fi'
Change commit message pattern:
GIT_SEQUENCE_EDITOR=: git rebase -i <base> --exec \
'git commit --amend -m "$(git log -1 --format=%B | sed s/old/new/)"'
Rearrange lines in the todo file. Example — move commit abc123 to the front:
# Build todo with abc123 first, then everything else in original order
{
echo "pick abc123 The commit to move first"
git rev-list --reverse <base>..HEAD | while read hash; do
full=$(git rev-parse abc123)
[ "$hash" != "$full" ] && echo "pick $hash $(git log --oneline -1 $hash | cut -d' ' -f2-)"
done
} > /tmp/prepared-todo
GIT_SEQUENCE_EDITOR="cp /tmp/prepared-todo" git rebase -i <base>
Remove lines from the todo, or change pick to drop.
NEVER use reword in the todo. The reword command opens an interactive editor for the new message, which cannot be scripted via GIT_SEQUENCE_EDITOR. Instead, use edit and amend with -m:
# Step 1: Prepare todo with 'edit' on commits to reword
# Step 2: At each stop, amend the message non-interactively:
git commit --amend -m "New subject line
New body text."
# Step 3: Continue to the next stop
git rebase --continue
Change pick to squash or fixup. For squash, you also need GIT_SEQUENCE_EDITOR for the commit message editor that opens after squashing:
# Squash second commit into first, keep first message
# In the todo: pick aaa, fixup bbb
GIT_SEQUENCE_EDITOR="cp /tmp/prepared-todo" git rebase -i <base>
…
指导在 JSI Runtime 层新增方法与功能,并同步 Hermes 与 SynthTrace 支持。
帮助开发者安全创建独立的 Git worktree 并智能选择目录