git rebase --continue won't work

GitGit Rebase

Git Problem Overview


I did git rebase master, fixed the conflicts reported in a file, and then git add the file to resolve the conflict. Then I did git rebase --continue, and got this:

> Applying: Fixed unit test > > No changes - did you forget to use 'git > add'? If there is nothing left to stage, chances are that something > else already introduced the same changes; you might want to skip this > 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".

Any idea what I am missing here? Should I do git rebase --skip?

Git Solutions


Solution 1 - Git

If you are in Mac OS X, then first of all you should disable revisiond, as it can mess with files in your work tree in the middle of rebase, causing unpredictable and broken behavior:

git config --global core.trustctime false

The issue is explained in this article, and big thanks to @nickfalk who pointed it out.

As for your rebase, this kind of situation is not unusual in practice. Let's try to think through the steps of what's happening:

  • When you rebase the current branch on top of another branch, git moves the HEAD to the other branch, and starts applying the unique commits you have in your current branch.

  • While replaying one of those commits, you reached a conflict. You resolved it, but as a result there are no changes to commit, nothing to replay in this commit.

Practically, this means that you rejected the changes in the current commit being replayed. So, if you don't need anything from this commit, it's normal to skip it. So git rebase --skip makes sense here.

Solution 2 - Git

I had a similar problem in my project and solved by putting the [--preserve-merges][1] option to the rebase command. In my project, this problem was caused by a merge commit, which is an "empty commit". Using git rebase --preserve-merges it takes the merge commit and continues the merge without breaking the commit tree.

[1]: https://git-scm.com/docs/git-rebase#git-rebase---preserve-merges "Git git rebase Documentation"

Solution 3 - Git

Breath, you're not going crazy! ;-= This is a known bug where OSX (if that is indeed what you're using) is messing with git, it is detailed here (not by me).

Short story (i.e. the fix) is:

git config --global core.trustctime false

Solution 4 - Git

I tried all the methods but nothing worked for me. If you are not in the middle of a rebase but git keeps complaining, then try the following. This worked for me for OSX.

rm -fr ".git/rebase-apply"

Solution 5 - Git

git add . will unblock you from this state, but if you resolved all conflicts by accepting the incoming changes, there is no diff to add so git thinks the conflict wasn't resolved as far as the rebase is concerned.

I took a low brow approach that worked without relying on side effects of using mysterious git config changes etc:

  • Added harmless content (eg // on one line) to each file in conflict (to give git something to add)
  • git add .
  • git rebase --continue
  • remove harmless comment

All sorted 

Solution 6 - Git

It could well mean that the changes are already rebased. Just check the git status.

Solution 7 - Git

None of the above suggestions worked. I found out that I had this issue because I did a hard reset of the master branch, while my feature branch had some legacy master commits (don't asked me how - no idea :( ).

I copied my changes out to a temporary directory, deleted my feature branch, copied them back in, and restarted from scratch. Ugly but effective. Not suggested if you're trying to keep more than one commit in your feature branch. Not suggested unless you have tried EVERYTHING ELSE.

UPDATE: This worked, but a better approach has been pointed out to me in the comments below. Take a look.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBoonView Question on Stackoverflow
Solution 1 - GitjanosView Answer on Stackoverflow
Solution 2 - GitEliseu EgewarthView Answer on Stackoverflow
Solution 3 - GitT. Benjamin LarsenView Answer on Stackoverflow
Solution 4 - GitVinoView Answer on Stackoverflow
Solution 5 - GitBohemianView Answer on Stackoverflow
Solution 6 - GitNeoView Answer on Stackoverflow
Solution 7 - GitGi0rgi0sView Answer on Stackoverflow