Git report merge file is deleted if it is not

I have a master branch and a function branch. Both contain the file Bar.cs. However, when I try to combine the function in master, it reports that the Bar.cs file has been deleted in the function branches. But Bar.cs has never been deleted by function, and, as I said, both files are present in both branches.

A git log of the Bar.cs file on the main returns the following:

commit daaf6bd6c8d2a38b839fae44234ceef2a0c9e188 Author: xxxx Date: Fri Jun 28 10:17:18 2013 +0000 Renamed Foo.cs to Bar.cs 

A git log of the function of the Bar.cs on file returns the following:

 commit 93dea9f7a2b9474c169bf8a49c5a721572a9d369 Author: xxxx Date: Fri Jul 5 16:14:46 2013 +0000 Another change commit de9fbe3ae13ccdac8a540c653af10abb1a2f1006 Author: xxxx Date: Tue Jul 2 16:03:43 2013 +0000 Renamed Foo.cs to Bar.cs 

As you can see, in the function, I combined the change with master on July 2, and then made another change in the file on June 28.

When I try to integrate, git says:

 CONFLICT (rename/delete): Bar.cs deleted in feature and renamed in HEAD. Version HEAD of Bar.cs left in tree. 

Any idea what is going on?

+4
source share
2 answers

Had the same problem when merging two branches synchronized from the SVN repository using the git-svn tool.

Some files were renamed to master branches and updated on feature branch, but git detected these files as deleted on feature side:

 CONFLICT (rename/delete): Classes/Am deleted in feature and renamed in HEAD. Version HEAD of Classes/Am left in tree. 

The solution was to change the merge strategy to resolve instead of the standard recursive :

 git merge -s resolve feature 
+3
source

Since the problematic commits seem to be exactly the same, you can try interactively reloading the feature ontop master :

 git checkout feature git rebase -i master 

an editor will appear that allows you to choose who makes the choice. Delete the line with commit de9fbe . Then all commits will be reapplied, except for renaming to feature .

Subsequently, the merger can be performed using

 git checkout master git merge --no-ff feature 
0
source

Source: https://habr.com/ru/post/1494946/


All Articles