简体   繁体   English

错误:如果没有先前的提交就无法“挤压”您可以使用“git rebase --edit-todo”修复此问题,然后运行“git rebase --continue”

[英]Error: cannot 'squash' without a previous commit You can fix this with 'git rebase --edit-todo' and then run 'git rebase --continue'

I have a below commits in bitbucket,i wanted to squash all the commits in to one commits.我在 bitbucket 中有以下提交,我想将所有提交压缩为一个提交。

When i do git rebase -i HEAD~5 ,it is showing all the commits in reverse order on git bash,where the last commit ie is Commit 5 is listed last.当我执行git rebase -i HEAD~5时,它会以相反的顺序显示 git bash 上的所有提交,其中最后一个提交即是最后一个提交。

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

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++

I tried below options.我尝试了以下选项。

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

I tried the above option,i got the below error.我尝试了上述选项,但出现以下错误。

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”。 Or you can abort the rebase with 'git rebase --abort'.或者你可以使用 'git rebase --abort' 中止 rebase。

Can any one plese help me how to squash all the 5 commits in to single commits,also let me know the steps to be followed for squashing all the 5 commits in to single commit.任何人都可以帮助我如何将所有 5 个提交压缩为单个提交,还让我知道将所有 5 个提交压缩为单个提交应遵循的步骤。

Thanks in Advance.提前致谢。

Normally, lines are executed in order up to down.通常,行是按从上到下的顺序执行的。

In order to squash everything this should work:为了压制一切,这应该起作用:

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

You reword and keep the first commit and squash all other.您改写并保留第一个提交并压制所有其他提交。 And if you want to delete messages of all your commits after commit 1, you should use f for fixup instead of squash..如果你想在提交 1 之后删除所有提交的消息,你应该使用ffixup而不是 squash..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM