Dean Rather
Dean Rather

Reputation: 32394

How to prevent a git merge conflict "Unmerged paths" "Added by them"

I'm merging branch B into branch A:

$ git checkout A
$ git merge B

I get the error:

# Unmerged paths:
#   (use "git add <file>..." to mark resolution)
# 
#   added by them:      path/to/file

What causes the git "Added by them" conflict, and how do I prevent it from happening?

Upvotes: 4

Views: 4925

Answers (1)

Dean Rather
Dean Rather

Reputation: 32394

Github have posted an excellent page explaining the various git conflicts, and how to avoid and resolve them.

Upon inspecting the conflict message (shown when attempting to do the original merge) I can see:

CONFLICT (rename/delete): file/to/path deleted in HEAD and renamed in B. Version B of file/to/path left in tree.

This explains how the problem came about, one branch deleted the file, when another branch moved it.

To prevent the problem, don't delete files in one branch and move them in another!

Upvotes: 2

Related Questions