Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git says a file is unmerged and I can't commit, but the file seems to be merged

I had about 12 file conflicts when I merged branches. I manually fixed all the conflicts and staged the files. But now when I try to commit, it says one of the files is unmerged.

U      app/models/disclosure_event.rb fatal: 'commit' is not possible because you have unmerged files. Please, fix them up in the work tree, and then use 'git add/rm <file>' as appropriate to mark resolution and make a commit, or use 'git commit -a'. 

When I type git status, it shows all the changed files, including "disclosure_event.rb", under Changes to be committed. It shows no files as unstaged. I've repeatedly tried to add the file, but it seems to do nothing. If I open the file, everything looks great.

Any ideas? I'm completely stuck.

like image 621
Adam Albrecht Avatar asked Jul 23 '11 02:07

Adam Albrecht


People also ask

How do you fix committing is not possible because you have unmerged files?

error: merge is not possible because you have unmerged files. hint: Fix them up in the work tree, and then use 'git add/rm <file>' hint: as appropriate to mark resolution and make a commit. fatal: Exiting because of an unresolved conflict.


2 Answers

I can't tell you what's wrong, but you might try

git reset app/models/disclosure_even.rb git add app/models/disclosure_even.rb 

and then commit.

like image 142
Ryan Stewart Avatar answered Oct 16 '22 03:10

Ryan Stewart


I had exactly the same situation today on branches merging (not rebasing).

I spot, that file it errors on, in your case:

U      app/models/disclosure_event.rb 

was absent in git status. But is could be seen as unmerged in gitk GUI. It also was absent in working copy (moved to another place in my case).

I tried git rm, and it solved the problem:

git rm app/models/disclosure_event.rb 
like image 36
alexkasko Avatar answered Oct 16 '22 04:10

alexkasko