Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resolve "CONFLICT (delete/modify)" in git

Tags:

git

In one branch in one branch A a file is changed and the change commited. Now in another branch B the very same file is edited and renamed.

When merging B into A git recognises the conflict properly (CONFLICT (delete/modify)) and both files are in the working directory.

If I know want to have both changes in one file, how do I do this best?

There is git merge-file that is - if I'm right - expecting both files and a common ancestor. But how to give latter? How can I say "use $path from $commit" or something like that?

Example:

mkdir git-rename-repo cd git-rename-repo git init  echo "First line" > afile  git add . git commit -m "First commit in master" git checkout -b mybranch  echo "Second line in mybranch" >> afile git mv afile bfile  git commit -a -m "change and rename in mybranch" git checkout master  echo "Changed first line in master" > afile  git commit -a -m "changed afile" git merge mybranch 

I now want a file named 'bfile' with both changes:

Changed first line in master Second line in mybranch

Thanks

like image 812
mokasin Avatar asked Feb 22 '10 21:02

mokasin


People also ask

How do I fix a merge conflict with deleted files?

Select Stage Changed Files To Commit (Ctrl-I) from Commit menu. Enter a commit comment like "deleted conflicting file" Commit (ctrl-enter) Now if you restart the merge it will (hopefully) work.


1 Answers

I also had the scenario

**CONFLICT (modify/delete):***FileName deleted in HEAD and modified in 6efb2a94ba0601aa1ec5050ab222a0359ee8379a. Version 6efb2a94ba0601aa1ec5050ab222a0359ee8379a of FileName left in tree.*

I was also equally confused and reached this post. But on typing git status, all doubts are vanished. git status, stated the following about the conflicted files:

Unmerged paths:
(use "git add/rm ..." as appropriate to mark resolution)

So I just did git rm FileName, and after that the CONFLICT got resolved.

like image 114
shah1988 Avatar answered Sep 20 '22 22:09

shah1988