Well, initially, we should know the root of the error, then the solution will become easy. The reason has already been pointed out by the accepted answer, but it's somehow incomplete (and also the solution).
The problem is, one or more files had conflicts previously, and Git still sees them as unresolved. Although you may already edited those files and resolved the conflicts, but Git is not aware of.
In this case, you should inform Git: "Hey, there are no conflicts from the previous merge!". Note that, the merge is not necessarily caused by a git merge
, but also by a git stash pop
, for example.
Generally, git status
can tell you what Git knows now. If there are some unresolved merge conflicts to Git, it is shown in a separated Unmerged paths
section, with the files marked as both modified
(always?). If you have noticed, this section is between two staged and unstaged sections. This means, unmerged paths are those you should either move into staged or unstaged areas, as Git can work only with these two.
Even in recent versions of Git, when you do a git status
, it tells you the how (woah! You should ask yourself how you haven't seen this yet):
$ git status
...
Unmerged paths:
(use "git restore --staged <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: path/to/file.txt
...
So, to stage it (and maybe commit it):
git add path/to/file.txt
And to make it unstaged (e.g. you don't want to commit it now):
git restore --staged path/to/file.txt
Note: Forgetting to write --staged
option could spawn a super-hungry dragon to eat your past two days, in the case of not using a good text-editor or IDE.
Note: While git restore
command is experimental yet, it should be stable enough to be used (thanks to a comment by @VonC, refer to it for more details on that).