Git: can't commit a file even though I've resolved the conflict

daGUY picture daGUY · Jun 28, 2012 · Viewed 10.8k times · Source

I pulled from origin to update my local, and one file had conflicting changes. I resolved the conflict, but I can't commit (locally) because git still thinks the file is conflicting:

$ git add style.css

This works - no errors or anything. Then:

$ git commit

Merge branch 'dev' of [origin] into dev

Conflicts:
        [path]/style.css
#
# It looks like you may be committing a MERGE.
# If this is not correct, please remove the file
#       .git/MERGE_HEAD
# and try again.
#

Why doesn't this work?

Answer

egore911 picture egore911 · Jun 30, 2012

I'll explain what basically happened here:

Your pull initiated a merge of the remote branch (because you did not do a rebase using the '-r' flag which would have done a rebase). The merge itself had a conflict and aborted (which also means your pull didn't finish). Now after you resolved the conflict you will have to add the conflicted file(s) and do a "git commit" to actually complete your pull (and the merge required for that). This will remove the file ".git/MERGE_HEAD" mentioned in your commit message which shows that you are currently in the middle of a merge.

After this you are in a clean state and everything should be fine.