How do I `git rebase -i` and prevent “You asked to amend the most recent commit, but doing so would make it empty.”?

前端 未结 4 553
天命终不由人
天命终不由人 2021-01-01 13:23

I want to run a git rebase -i some-hash.

When I run it, I get the error:

You asked to amend the most recent commit, but doing so

4条回答
  •  旧巷少年郎
    2021-01-01 13:34

    I found the simplest solution was to just interactively rebase (git rebase -i {some head}) and then drop the commits that were causing issues (with d in the rebase screen).

    If you know that the commits are direct mirrors of each other (squashing them will result in an empty commit), and trying to squash through rebase isn't working then simply removing the commits themselves works.

    As painful as it sounds, you're fiddling with the history anyway so it helps to clean up.

提交回复
热议问题