【发布时间】:2021-06-05 02:50:04
【问题描述】:
我在 bitbucket 中有以下提交,我想将所有提交压缩到一个提交中。
当我执行git rebase -i HEAD~5 时,它会在 git bash 上以相反的顺序显示所有提交,其中最后一次提交,即 Commit 5 列在最后。
pick 104e52ffdb IA-31774 Commit 1
pick 157be0f3b3 IA-31774 Commit 2
pick 4619cf38be IA-31774 Commit 3
pick e89937fca9 IA-31774 Commit 4
pick 38c54ea317 IA-31774 Commit 5
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++
我尝试了以下选项。
s 104e52ffdb IA-31774 Commit 1
s 157be0f3b3 IA-31774 Commit 2
s 4619cf38be IA-31774 Commit 3
p e89937fca9 IA-31774 Commit 4
r 38c54ea317 IA-31774 Commit 5
我尝试了上述选项,但出现以下错误。
error: cannot 'squash' without a previous commit 你可以用 'git rebase --edit-todo' 然后运行 'git rebase --continue'。或者你 可以使用 'git rebase --abort' 中止 rebase。
谁能帮助我如何将所有 5 个提交压缩为单个提交,也请告诉我 将所有 5 个提交压缩为单个提交所要遵循的步骤。
提前致谢。
【问题讨论】:
-
squash命令的意思是:“将这个提交压缩到前一个提交中。”也就是说,您的第一个s应该保留为pick,以便您后续的s命令在它们之前找到一些提交,它们可以被压缩。