【问题标题】:Error: cannot 'squash' without a previous commit You can fix this with 'git rebase --edit-todo' and then run 'git rebase --continue'错误:如果没有先前的提交就无法“挤压”您可以使用“git rebase --edit-todo”修复此问题,然后运行“git rebase --continue”
【发布时间】: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 命令在它们之前找到一些提交,它们可以被压缩。

标签: git github bitbucket


【解决方案1】:

通常,行是按从上到下的顺序执行的。

为了压制所有应该工作的东西:

r 104e52ffdb IA-31774 Commit 1
s 157be0f3b3 IA-31774 Commit 2
s 4619cf38be IA-31774 Commit 3
s e89937fca9 IA-31774 Commit 4
s 38c54ea317 IA-31774 Commit 5

您改写并保留第一次提交并压制所有其他提交。 如果你想在提交 1 之后删除所有提交的消息,你应该使用 f 代替 fixup 而不是 squash..

【讨论】:

  • 感谢您的建议..我会尝试..如果我想删除我所有提交的消息而不是 squash,您提到使用 fixup。 1.如果我使用修复,我所有的提交信息都会被删除是不是......我也收到了来自开发者的cmets,它会被删除吗?请确认。 2.如果我按照你提到的第一次提交来做,你能告诉我 wat reword 会做吗?请确认
  • @SSL:哪些 cmets?提交消息或 bitbucket 或 github 上的那些?您在帖子中使用了 reword,它允许您在不更改内容的情况下更改提交消息。
猜你喜欢
  • 2018-03-22
  • 2017-09-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-04
  • 1970-01-01
  • 2011-09-11
  • 2013-06-12
相关资源
最近更新 更多