运行 interactive rebase 时我之前的提交是哪一个?
Which one is my previous commit when running interactive rebase?
当我 运行 类似 git rebase -i --rebase-merges eeb1425e0
我的提交列表显示颠倒,即第一个提交是最后一个,最后一个提交是第一个:
pick A Penultimate commit
pick B Penult commmit
pick C Latest commit
# Rebase eeb1425e..5a3f045b onto eeb1425e (288 commands)
#
# 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.
#
# Note that empty commits are commented out
然后,当压缩选项显示 squash = use commit, but meld into previous commit
时,我按下 squash
如下:
pick A Penultimate commit
squash B Penult commmit
pick C Latest commit
B
的上一次提交是 A
还是 C
? B
是 merged/squashed 还是 A
还是 C
?
相关:
- How can I merge two commits into one if I already started rebase?
- What exactly does git's "rebase --preserve-merges" do (and why?)
提交顺序确实与您通常使用 git log
看到的顺序相反,因此:
pick A Penultimate commit
pick B Penult commmit
pick C Latest commit
如果将第二行更改为 squash
,Git 将:
- cherry-pick 提交
A
到 begin 进行新的提交,但尚未完成;
- 在实际进行新提交之前将提交
B
压缩到其中;和
- cherry-pick 提交
C
进行第二次新提交;
给你我喜欢画的图画,如:
A--B--C [abandoned]
/
...--o--o--AB--C' <-- branch-name
这里的 A-B-C
链是原来的三个提交,最后一个画在右边(而不是顶部或底部),新的 AB-C'
链是两个新的提交,再次与右侧绘制的最后一个。您的分支名称用于标识提交 C
,现在标识新副本 C'
.
旁注:倒数第三个词是 antepenultimate。例如,"Penultimate" 字面意思是 "second from last". If there is a fourth from last you need to identify, this is the preantepenultimate. There appears to be no English-language word for "fifth from last". Following links here arrives at propreantepenultimate, but see the status at the Collins dictionary。
另一个旁注:interactive rebase 愿意进行提交然后取消提交,因此上面的描述 ("squash before actually making commit") 只是 shorthand 您将 看到的 当您查看结果时,而不是对底层机制的完整描述。实际的提交集可能包括额外放弃的临时提交。 Git 最终会自行清理所有这些。
当我 运行 类似 git rebase -i --rebase-merges eeb1425e0
我的提交列表显示颠倒,即第一个提交是最后一个,最后一个提交是第一个:
pick A Penultimate commit
pick B Penult commmit
pick C Latest commit
# Rebase eeb1425e..5a3f045b onto eeb1425e (288 commands)
#
# 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.
#
# Note that empty commits are commented out
然后,当压缩选项显示 squash = use commit, but meld into previous commit
时,我按下 squash
如下:
pick A Penultimate commit
squash B Penult commmit
pick C Latest commit
B
的上一次提交是 A
还是 C
? B
是 merged/squashed 还是 A
还是 C
?
相关:
- How can I merge two commits into one if I already started rebase?
- What exactly does git's "rebase --preserve-merges" do (and why?)
提交顺序确实与您通常使用 git log
看到的顺序相反,因此:
pick A Penultimate commit pick B Penult commmit pick C Latest commit
如果将第二行更改为 squash
,Git 将:
- cherry-pick 提交
A
到 begin 进行新的提交,但尚未完成; - 在实际进行新提交之前将提交
B
压缩到其中;和 - cherry-pick 提交
C
进行第二次新提交;
给你我喜欢画的图画,如:
A--B--C [abandoned]
/
...--o--o--AB--C' <-- branch-name
这里的 A-B-C
链是原来的三个提交,最后一个画在右边(而不是顶部或底部),新的 AB-C'
链是两个新的提交,再次与右侧绘制的最后一个。您的分支名称用于标识提交 C
,现在标识新副本 C'
.
旁注:倒数第三个词是 antepenultimate。例如,"Penultimate" 字面意思是 "second from last". If there is a fourth from last you need to identify, this is the preantepenultimate. There appears to be no English-language word for "fifth from last". Following links here arrives at propreantepenultimate, but see the status at the Collins dictionary。
另一个旁注:interactive rebase 愿意进行提交然后取消提交,因此上面的描述 ("squash before actually making commit") 只是 shorthand 您将 看到的 当您查看结果时,而不是对底层机制的完整描述。实际的提交集可能包括额外放弃的临时提交。 Git 最终会自行清理所有这些。