交互式rebase之间有什么不同,例如:
git rebase -i HEAD~3
没有-i
的反叛:
git rebase HEAD~3
答案 0 :(得分:2)
正如托马斯爱德华兹评论的那样,这里的文档很有用。与pro git book一样(特别是rebasing和rewriting history上的部分。
在它的核心,rebase将检查根提交并逐个应用一系列提交。
当您进行常规变基(git rebase HEAD~3
)时,会自动发生这种情况。
但是当您执行交互式rebase(git rebase -i HEAD~3
)时,您将有机会编辑提交。
这可能看起来像修改提交消息,压缩提交,编辑提交中的更改甚至完全删除提交!
答案 1 :(得分:1)
交互式rebase将打开一个编辑器,其中包含即将更改的提交列表。此列表接受命令,允许用户在启动rebase操作之前编辑列表。
答案 2 :(得分:1)
命令:
答案 3 :(得分:1)
Normal Rebase
它不接受任何用户输入,因此它从分支中选择了所有提交而没有任何修改,并应用了所有提交。
Interactive Rebase
它会打开您面前的编辑器,以便我们可以按所需方式对每个提交进行任何类型的修改。如下所示
交互式基础提交提交编辑器
pick <commit_hash> <commit_message>
pick 42522f0 add stack implementation
# Rebase 6aa416b..42522f0 onto 6aa416b (1 command)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# . create a merge commit using the original merge commit's
# . message (or the oneline, if no original merge commit was
# . specified). Use -c <commit> to reword the commit message.
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
在正常的基准更改中,它会自动完成,并且默认情况下会选择所有提交,而不是任何修改(更改,编辑或删除等)
如果您一次提交,最好使用normal rebase
,反之亦然。