2

I'm new to git and when I try to merge one branch into another, I'm getting a bunch of errors, like this:

CONFLICT (modify/delete): src/controller/app.js deleted in feat_branch and modified in HEAD. Version HEAD of src/controller/app.js left in tree.
CONFLICT (modify/delete): src/controller/service.js deleted in feat_branch and modified in HEAD. Version HEAD of src/controller/service.js left in tree.
...

Im trying to merge using this command git merge feat_branch --no-ff

What am I doing wrong or why this is generating these errors?

celsomtrindade
  • 3,931
  • 14
  • 48
  • 105

1 Answers1

3

These are not errors. They are merge conflicts (note, git does itself not use the word "error" here, but says "conflict").

This is an important distinction: conflicts are normal and harmless in git. They mean work for you, but are not a problem. Git is very good at keeping conflicts as small as possible (as opposed to some older version control systems), and also is usually very explicit and helpful with its messages.

In this case, the conflict is exactly what it says: someone deleted the files in feat_branch, but you modified the same file meanwhile. If you had not modified the file since the start of feat_branch, git would just have deleted it during the merge. If they had not deleted it, your changes would just have been kept. But in this case, git demands a human decision, since you obviously had another intent than the guy/girl deleting the file.

If you type git status, you will get a helpful note that gives you a hint on which commands pick which resolution (i.e., either delete the file or keep it).

AnoE
  • 6,874
  • 1
  • 14
  • 28