2

I'm in an interactive rebase and have marked the commits on which I need to have a closer look with edit (e) now while looking into the commits I realize that some of the commits need to be dropped/removed. Which is the correct commit to do that within the interactive mode?

Currently I perform the following commands:

$ git reset HEAD^
$ git checkout -- <File> # <- here I list all of the files that need to be reset
$ git rebase --continue # this complains that I have to perform git commit --allow-empty or git reset
# since I don't want the empty commit I do …
$ git reset
$ git rebase --continue

This is very lengthy. So I tried

$ git reset --hard HEAD^
$ git rebase --continue

But that produces a merge conflict.

So what is the easiest way to drop the current commit, when beeing in the edit mode of an interactive rebase?

danronmoon
  • 3,814
  • 5
  • 34
  • 56
white_gecko
  • 4,808
  • 4
  • 55
  • 76

2 Answers2

2

So what is the easiest way to drop the current commit, when beeing in the edit mode of an interactive rebase?

For me, the easiest way, by far, is to make a note of the commit I want to drop (subject line and any other identifying marks), finish the interactive rebase, and start a new interactive rebase and mark the commit as "drop". There is no need to do it all at once!

torek
  • 448,244
  • 59
  • 642
  • 775
0

If you git reset --hard you are also losing the changes of the current commit, hence the conflicts I suppose. Instead you could do a mixed reset with

git reset HEAD^

And amend the last commit with the changes in the current commit:

git add your_changes
git commit --amend -m "new commit message"
Marco Luzzara
  • 5,540
  • 3
  • 16
  • 42