- 最好在压缩提交前创建 backup 分支,以备不时之需
- 如需练习,请查看练习题压缩习题一
# 变基前
---a---b---c master
\
d---e---f topicA
\
g---h---i HEAD -> topicB, backup
pick 3360d12 <第一次提交信息>
pick bc293e2 <第二次提交信息>
pick 1726edf <第三次提交信息>
# Rebase d65c58e..1726edf onto d65c58e (3 commands)
#
# Commands:
# p, pick = use commit 正常选中
# r, reword = use commit, but edit the commit message 选中,并且修改提交信息;
# e, edit = use commit, but stop for amending 选中,rebase时会暂停,允许你修改这个commit(参考这里)
# s, squash = use commit, but meld into previous commit 选中,会将当前commit与上一个commit合并
# f, fixup = like "squash", but discard this commit's log message 与squash相同,但不会保存当前commit的提交信息
# x, exec = run command (the rest of the line) using shell 执行其他shell命令
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
r 3360d12 <第一次提交信息>
s bc293e2 <第二次提交信息>
s 1726edf <第三次提交信息>
# Rebase d65c58e..1726edf onto d65c58e (3 commands)
#
# Commands:
# p, pick = use commit 正常选中
# r, reword = use commit, but edit the commit message 选中,并且修改提交信息;
# e, edit = use commit, but stop for amending 选中,rebase时会暂停,允许你修改这个commit(参考这里)
# s, squash = use commit, but meld into previous commit 选中,会将当前commit与上一个commit合并
# f, fixup = like "squash", but discard this commit's log message 与squash相同,但不会保存当前commit的提交信息
# x, exec = run command (the rest of the line) using shell 执行其他shell命令
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
<第一次提交信息>
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Thu May 3 19:59:00 2018 +0800
#
# interactive rebase in progress; onto d65c58e
# Last command done (1 command done):
# r 3360d12 g
# Next commands to do (2 remaining commands):
# s bc293e2 h
# s 1726edf i
# You are currently editing a commit while rebasing branch 'topicB' on 'd65c58e'.
#
# Changes to be committed:
# new file: g#
<新的提交信息>
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Thu May 3 19:59:00 2018 +0800
#
# interactive rebase in progress; onto d65c58e
# Last command done (1 command done):
# r 3360d12 g
# Next commands to do (2 remaining commands):
# s bc293e2 h
# s 1726edf i
# You are currently editing a commit while rebasing branch 'topicB' on 'd65c58e'.
#
# Changes to be committed:
# new file: g#
# This is a combination of 3 commits.
# This is the 1st commit message:
<新的提交信息>
# This is the commit message #2:
<第二次提交信息>
# This is the commit message #3:
<第三次提交信息>
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Thu May 3 19:59:00 2018 +0800
## interactive rebase in progress; onto d65c58e# Last commands done (3 commands done):# s bc293e2 h# s 1726edf i# No commands remaining.
# You are currently rebasing branch 'topicB' on 'd65c58e'.## Changes to be committed:# new file: g# new file: h# new file: i
#
# This is a combination of 3 commits.
<新的提交信息>
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Thu May 3 19:59:00 2018 +0800
## interactive rebase in progress; onto d65c58e# Last commands done (3 commands done):# s bc293e2 h# s 1726edf i# No commands remaining.
# You are currently rebasing branch 'topicB' on 'd65c58e'.## Changes to be committed:# new file: g# new file: h# new file: i
#
# 变基前
---a---b---c master
\
d---e---f topicA
\
g---h---i HEAD -> topicB, backup
# 变基后
---a---b---c master
\
d---e---f topicA
|\
| g---h---i backup
\
ghi HEAD -> topicB