4

I had a pretty big merge conflict which I solved. I cannot commit to resolve the confict, though.

When I want to commit with git commit - m "Resolved conflicts" I get an error like this

error: Merging is not possible because you have unmerged files.

When I look at git status, I can see that in my branch and the merged branch, a file is deleted - which is recognised by git:

enter image description here

You can see that in the both deleted notation.

I cannot - as suggested - add or remove the files. I get the error that the file is missing. This is correct because the file is deleted and therefore not on the file system.

Any ideas?

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
Ron
  • 22,128
  • 31
  • 108
  • 206

1 Answers1

5

Alright, finally a solution!

You have to add every deleted file with the -u flag!

git add -u <file>

Quote from the docs about this flag:

-u --update

Update the index just where it already has an entry matching . This removes as well as modifies index entries to match the working tree, but adds no new files.

If no is given when -u option is used, all tracked files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
Ron
  • 22,128
  • 31
  • 108
  • 206
  • 3
    `git add ` *without* `-u` will work too, even though the file does not exist. `git rm ` works even though it complains that the file is not there in the work-tree. In any case, if you want to use `-u` to finish everything at this point, you can use it *without* paths, as just `git add -u`, to update all the remaining removed files. – torek Dec 17 '19 at 18:00
  • It took me ages to update all files. Great input that you can leave out the path! – Ron Dec 18 '19 at 16:46