Unable to continue with rebase due to untracked working tree files would be overwritten by merge error

Viewed 8138

I'm currently mergin two branches using git rebase -i, There is a commit that is not letting me continue with the rebase. When I check the commit I see that there are some files but nothing is conflicting with the branch.

enter image description here

I tried using the fixup and edit because I thought maybe I had made some changes, however this is not the case. When I run git rebase --continue I get the following message:

error: The following untracked working tree files would be overwritten by merge:

It also shows files as shown in the image above with the following message

Please move or remove them before you merge.
Aborting
hint: Could not execute the todo command
hint: 
hint:     pick 430847f3fe3f80162a93f62db3e016f3c9a97cc1 Include html2text package
hint: 
hint: It has been rescheduled; To edit the command before continuing, please
hint: edit the todo list first:
hint: 
hint:     git rebase --edit-todo
hint:     git rebase --continue

What can I do in this case? Does this mean, I can rebase this commit? Do I have to abort?

3 Answers
error: The following untracked working tree files would be overwritten by merge:

This means exactly what it says: some file(s) exist in your work-tree but not in your index, so they are untracked. Proceeding with the next git cherry-pick that is part of the git rebase sequence will overwrite them. (The main tricky bits here are that git rebase mainly consists of a series of git cherry-pick commands, and that git cherry-pick uses Git's merge mechanism, so that even though you're doing a git rebase you are getting some files merged.)

... But I don't see those file in the folder it says the are. There is no vendor/soundasleep folder when I check atom ...

That's the truly puzzling part. Git definitely sees the files as existing in your work-tree. Note that if you're on a typical Windows or MacOS system, the underlying file system does case-folding, so if there is a vendor/SoundAsleep folder, or a VENDOR/soundasleep folder, or anything along those lines, that also counts.

(I don't use the atom editor and would do any inspecting outside it, myself.)

The problem is that I had the following in my .gitignore file.

!/vendor/soundasleep

Therefore, I was unable to continue with the merge and not see the files in my editor. I did the following to add the files.

git add vendor/soundasleep

and then I was able to git rebase --continue

NOTE: If you encounter this kind of error and you don't see the files in your editor check your .gitignore file and add the files or delete them manually. For me since I wanted to keep the changes, I git add vendor.soundasleep fixed it.

In my case it was because of diff in both .gitignore & .idea (untracked). I closed IDE, removed .idea folder. Rebase was successfull.

Related