Git rebase --continue complains even when all merge conflicts have been resolved

GitRebase

Git Problem Overview


I am facing an issue that I am not sure how to resolve.

I did a rebase against master from my branch:

git rebase master

and got the following error

 First, rewinding head to replay your work on top of it...
 Applying: checkstyled.
 Using index info to reconstruct a base tree...
 Falling back to patching base and 3-way merge...
 Auto-merging AssetsLoader.java
 CONFLICT (content): Merge conflict in AssetsLoader.java
 Failed to merge in the changes.
 Patch failed at 0001 checkstyled.

So I went to my favourite editor, fixed the 1 line conflict, saved the file and did a git status and got the following output:

 # Not currently on any branch.
 # Changes to be committed:
 #   (use "git reset HEAD <file>..." to unstage)
 #
 #	modified:   PassengerContactHandler.java
 #
 # Unmerged paths:
 #   (use "git reset HEAD <file>..." to unstage)
 #   (use "git add/rm <file>..." as appropriate to mark resolution)
 #
 #	both modified:      AssetsLoader.java
 #
 

I did a git add AssetsLoader.java and a git status and got the following:

 # Not currently on any branch.
 # Changes to be committed:
 #   (use "git reset HEAD <file>..." to unstage)
 #
 #	modified:   AssetsLoader.java
 #	modified:   PassengerContactHandler.java
 #

and when I did git rebase --continue I get:

git rebase --continue
You must edit all merge conflicts and then
mark them as resolved using git add

I know I can skip the patch and continue the rebase, but I am not sure if the changes in PassengerContactHandler.java will be rebased into my branch or not.

so I am not sure, How should I proceed?

Edit: Could it be that the file with the resolved conflict is exactly like the original version?

Thanks a lot, Lucas

Edit, it just happened to me again:

It just happened to me again,

(307ac0d...)|REBASE)$ git status
# Not currently on any branch.
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	modified:   assets/world/level1/Level-1.xml
#	modified:   George.java
#	modified:   DefaultPassenger.java
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	mb-art/originalAssets/27dec/

((307ac0d...)|REBASE)$ git rebase --continue

You must edit all merge conflicts and then
mark them as resolved using git add

git --version

git version 1.7.1


      

Git Solutions


Solution 1 - Git

This happens because when fixing a conflict, you removed all code in the patch beeing applied to the branch you are rebasing on. If you are sure you have added all your changes: Use git rebase --skip to continue.

A bit more details:

Normally, when fixing a conflict during rebasing, you will edit the conflicting file, keeping some or all of the code in the patch currently being applied to the branch you rebase on. After fixing the patch and doing

git add your/conflicted/file
git status

you will get a (usually green) line showing the modified file

> modified: your/conflicted/file

git rebase --continue will work fine in this situation.

Sometimes, however, when resolving the conflict, you remove everything in your new patch, keeping only code from the branch you rebased on. Now when you add the file, it will be exactly like the one you tried to rebase on. git status will show no green line displaying the modified files. Now, if you do

git rebase --continue

git will complain with

> No changes - did you forget to use 'git add'?

If you are sure you have added all your changes, what git actually wants you to do in this situation is to use

git rebase --skip

to skip the patch. Previously I never did this, as I was always unsure what would actually be skipped if I did, it was not obvious to me what "skip this patch" really meant. But if you get no green line with

> modified: your/conflicted/file

after editing the conflicted file, adding it, and doing git status, then you can be pretty sure you removed the whole patch, and you can instead use

git rebase --skip

to continue.

> The original post said this sometimes works: > > git add -A > git rebase --continue > # works magically?

... but don't rely on this (and be sure not to add leftover files in your repository folders)

Solution 2 - Git

Seems to be a bug in Git 1.7

Here's a good article on how to solve this.

Basically it should work, if you do a

git diff

after resolving your conflicts and then

git rebase --continue

should work.

Solution 3 - Git

I got this warning when I had unstaged files. Make sure you don't have any unstaged files. If you don't want the unstaged files changes, then discard the changes with

git rm <filename>  

Solution 4 - Git

Once you fixed your changes you might forget to run 'git add -A'

git add -A
git rebase --continue

Solution 5 - Git

After fixing the conflict, make sure the changed files(s) are added to your staged files. This solved the problem for me.

Solution 6 - Git

Try running this in your command line:

$ git mergetool

Should bring up an interactive editor allowing you to resolve the conflicts. Easier than trying to do it manually, and also git will recognize when you do the merge. Will also avoid situations where you don't fully merge by accident that can happen when you try to do it manually.

Solution 7 - Git

Ive just had this problem, and whilst I think there might be a few causes, here's mine...

I had a git pre-commit hook which rejected commits under certain conditions. This is fine when committing manually, since it will display the output of the hook, and I can either fix it or choose to ignore it using commit --no-verify.

The problem seems to be that when rebasing, rebase --continue will also call the hook (in order to commit the lastest bout of changes). But rebase will not display the hook output, it'll just see that it failed, and then spit out a less specific error saying 'You must edit all merge conflicts and then mark them as resolved using git add'

To fix it, stage all your changes, and instead of doing 'git rebase --continue', try a 'git commit'. If you are suffering from the same hook problem, you should then see the reasons why its failing.

Interestingly, whilst git rebase doesn't display the output from git hook, it does accept a --no-verify to bypass the hooks.

Solution 8 - Git

You missed a merge conflict in AssetsLoader.java. Open it up and look for conflict markers (">>>>", "====", "<<<<<") and then do git add again. Do a 'git diff --staged' if you're having difficulty finding it.

Solution 9 - Git

I just stumbled on the issue. I would not git rebase --skip because git status clearly show modifications stagged, which I wanted to keep. Though I had some extra files that came unexpectedly. I resolved with

git checkout .

to remove unstagged modifications, then git rebase --continue succeeded.

Solution 10 - Git

If you are using magit (a popular emacs frontend to git), this error message can be shown due to an obscure bug in magit. I'm not exactly sure what triggers this bug, but for me it was that only the line endings were changed for a file, and so magit didn't display the file as a conflict. So I thought there were no conflicts remaining, but there were. Running git status at the command line allowed me to see the conflicting file, and I could then run git add filename and then git rebase --continue.

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
QuestionLucasView Question on Stackoverflow
Solution 1 - GitjonasfhView Answer on Stackoverflow
Solution 2 - GitacmeView Answer on Stackoverflow
Solution 3 - GitScottyBladesView Answer on Stackoverflow
Solution 4 - GitgsalgadotoledoView Answer on Stackoverflow
Solution 5 - GitprimulaverisView Answer on Stackoverflow
Solution 6 - GitBatkinsView Answer on Stackoverflow
Solution 7 - GitcarpiiView Answer on Stackoverflow
Solution 8 - GitEtherView Answer on Stackoverflow
Solution 9 - GitGhislainView Answer on Stackoverflow
Solution 10 - GitRobin GreenView Answer on Stackoverflow