Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 330
Dean Rather Avatar asked Apr 20 '26 03:04

Dean Rather


1 Answers

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!

like image 162
Dean Rather Avatar answered Apr 21 '26 16:04

Dean Rather



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!