3

I want to merge master branch into my development branch. While in my development branch, I execute the following:

''' git pull origin master'''

When I do this, the merge finishes, however, I notice very odd behavior. It seems that a folder in master is so similar to my branch, it treats them as the same folder.

I have tried creating a new branch from master and pull in the changes from development into master, but it does the same thing. It treats the folders as if they are the same.

For example, I have the following:

Master src->folder1

Development src->folder2

After the merge, I get

Developement src->folder1

instead of

Developement src->folder1 src->folder2

EDIT: The file names are mostly identical, however, the contents of the files are not identical at all. Development is done in C++, so the namespaces make it clear who is what.

EDIT: Hey gang, I tried the recommendations, however, git was still doing the renaming. Instead, I just branched from master and brought in the folders I needed. Now when I merge master, it is always up-to-date. Thanks for all the suggestions!

user2899525
  • 105
  • 10
  • What are the contents of the folders? If the folders contain identical files, it probably thinks you intended to rename the folder, because obviously no one would ever want to have identical files in two different folders. ;) – TTT Jul 18 '19 at 16:51
  • Possible duplicate of [Disable Git Rename Detection](https://stackoverflow.com/questions/6013261/disable-git-rename-detection) – TTT Jul 18 '19 at 16:56
  • What do you mean by "folders are similar"? Do you mean the files in the folders are similar? – Code-Apprentice Jul 18 '19 at 17:20
  • They are similar in that 90% of the file names are the same. Having said that, the contents of the file are much different. – user2899525 Jul 19 '19 at 00:53

2 Answers2

2

I believe the feature that is being triggered here is "rename detection". Because git only records snapshots, not the intent of changes, file moves, copies, and renames are detected by comparing the contents of files. It seems that in your case, git is detecting the contents as being sufficiently similar that it probably represented a rename on one branch or the other.

You can disable this behaviour:

IMSoP
  • 89,526
  • 13
  • 117
  • 169
0

I believe that your problem is due to directory rename detection. You can turn it off with

git -c merge.directoryRenames=false pull origin master

This leaves normal rename detection operative.

j6t
  • 9,150
  • 1
  • 15
  • 35