Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to proceed when Git rebase --continue is REALLY REALLY blocked by empty commit

I am rebasing a branch of several commits onto an upstream branch. I am blocked by a failure of some kind where I can't continue to the remaining commits in my branch, so I need a way to continue when git reset does not seem to work.

As I said I'm rebasing a branch. I do rebasing like this all the time, and I am not surprised that one or two commits have conflicts that resolve down to empty commits. But I don't know which commits until I go through the conflict resolution steps (editing the files that conflict and adding the resulting files). So here's an abstracted version of what happened:

$ git checkout working_branch
$ git rebase -i upstream
 [Here it is reported that file.c has conflicts. I edit it.
  The resulting diff is empty.]
$ git add file.c
$ git rebase --continue
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:

  git commit --allow-empty

Otherwise, please use 'git reset'
rebase in progress; onto xxxsha

However at this point git reset is of no help, I end up with the same exact status. I don't wish to have an empty commit. I have come upon potential empty commits from this process before and I have always been very happy to have the commit disappear.

I came upon the question git cherry-pick not working in which almost the same exact results occur, but from cherry-picking one commit, not rebasing a branch. The other inquirer was happy to just go ahead and not do the cherry-pick. Stepwise I guess rebase uses cherry-pick for each commit, I have several commits to step through. In my case this happened on the first commit of my branch and I need a real solution to continue.

like image 847
cardiff space man Avatar asked Aug 04 '17 18:08

cardiff space man


People also ask

How do I force git to rebase continue?

git/rebase-apply/patch When you have resolved this problem, run "git rebase --continue". If you prefer to skip this patch, run "git rebase --skip" instead. To check out the original branch and stop rebasing, run "git rebase --abort".

Do I need to commit before git rebase -- continue?

For each change you make, you'll need to perform a new commit, and you can do that by entering the git commit --amend command. When you're finished making all your changes, you can run git rebase --continue . As before, Git is showing the commit message for you to edit.

How do you rebase without going through each commit?

If you don't want rebase to stop at each commit if you get any merge conflicts and want it to stop only once during the rebase process, you can squash all the commits into one in your fix/align-div-vertically branch by squashing them using interactive rebase before rebasing with the master.


1 Answers

The take-away is to look carefully at the summary line. The answer turns out to be git rebase --continue if you notice that the summary line of the commit it says cannot be applied, is actually the next commit. I was thrown off by how similar the text on screen was to the usual empty commit message that the command often shows. But it was a different kind of message. It had in fact continued on, and was working on the next commit, which was automatically resolved as empty. The text included the summary line from the next commit of the branch, instead of the summary line from the commit I had just resolved. So when the empty commit status comes up in this way, it is okay to just continue again without further ado.

like image 99
cardiff space man Avatar answered Sep 22 '22 11:09

cardiff space man