在交互式 git rebase 期间是否有再次返回的技巧?让我们这样说:
git init
for c in a b c; do
touch $c && git add $c && git commit -m $c
done
现在假设我开始一些交互式 rebase ,如下所示:
git rebase -i --root
# p 5e2df3f a
# e b87116d b
# p a55558f c
并且,编辑后b
根据我的喜好 - 也许可以在 git reset HEAD^ -p
之后将其分成两个提交,我最终得到:
git commit --amend
touch b2 && git add b2 git commit -m "b''"
git log --oneline
# a5f42cc (HEAD) b''
# 5446996 b'
# 5e2df3f a
我现在如何向后跳,而不必先完成 rebase 直到最后? IE。就在这个阶段我会看到:
git rebase --edit-todo
# p a55558f c
但是如果我在新的 5446996 b'
中犯了一个错误怎么办?犯罪?如果我意识到我必须修改 5e2df3f a
中的其他内容怎么办?这最初是我的 rebase 编辑待办事项的开始?
我能以某种方式跳回来吗 - 就像嵌套的 git rebase -i
(这是不允许的)?或者还有其他方法可以实现这一目标吗?
我明确不想必须完成我所在的 rebase ,然后再次重新启动它。
谢谢!
最佳答案
您只需手动重播嵌套 rebase 会执行的操作。也就是说,您可以返回到提交并修复它:
git checkout 5446996
# edit
git commit -a --amend
然后你挑选剩余的提交:
git cherry-pick 5446996..a5f42cc
如有必要,修复冲突并gitcherry-pick --Continue
。
然后使用 git rebase --continue
完成 rebase 。
关于git:在交互式 rebase 期间再次跳回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69673695/