交互式变基和普通变基有何不同?例如:
git rebase -i HEAD~3
不使用-i
进行变基:
git rebase HEAD~3
交互式变基和普通变基有何不同?例如:
git rebase -i HEAD~3
不使用-i
进行变基:
git rebase HEAD~3
命令:
普通变基
它不需要任何用户输入,因此选择分支中的所有提交而不进行任何修改并应用所有提交。
交互式变基
它会在你面前打开编辑器,以便我们可以按照自己的方式对每个提交进行任何修改。就像下面给出的一样。
交互式变基提交编辑器
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.
git rebase --help
并阅读文档,你会发现一些很好的例子,说明了为什么以及如何使用它。 - Zoe Edwards