{"thread":{"id":"45952","subject":"git subtree merge deletes files in top directory","startedAt":"2017-05-13T09:17:31Z","lastAt":"2017-05-13T09:17:31Z","messageCount":1,"participants":["Nikolai Hartmann"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"319606","messageId":"aa3f2a1c-42d2-06df-9823-c455c798ffb0@gmx.de","threadId":"45952","inReplyTo":null,"subject":"git subtree merge deletes files in top directory","fromName":"Nikolai Hartmann","fromEmail":"nikolai.hartmann@gmx.de","sentAt":"2017-05-13T09:20:56Z","receivedAt":"2017-05-13T09:17:31Z","isPatch":false,"sender":{"key":"nikolai.hartmann@gmx.de","avatar":null},"body":"Hi,\n\nI'm trying to add a subtree which contains a folder with the same name\nas the subtree directory itself.\nAdding seems to work, but if i pull after the subtree remote changed,\nfiles in my top directory are deleted and everything seems to have\n\"moved up\" one directory - although i specify a subtree directory with \"-P\"\n\nFor example i start with top repository that contains one file:\n\n.\n└── topfile\n\nNow i try to add another repository as a subtree which looks like this:\n\n.\n├── afile\n└── subrep\n    └── anotherfile\n\nRunning `git subtree add -P subrep origin_subrep master --squash` on the\ntop repository produces correctly\n\n.\n├── subrep\n│   ├── afile\n│   └── subrep\n│       └── anotherfile\n└── topfile\n\nNow i change the subrep git by just adding files\n\n.\n├── afile\n├── bfile\n└── subrep\n    ├── anotherfile\n    └── yetanotherfile\n\nWhen i try to merge these into the top repository by `git subtree pull\n-P subrep origin_subrep master --squash` i get\n\n[...]\nRemoving topfile\nRemoving subrep/subrep/anotherfile\nRemoving subrep/afile\nMerge made by the 'recursive' strategy.\n subrep/subrep/anotherfile => anotherfile | 0\n subrep/afile                             | 0\n topfile => yetanotherfile                | 0\n 3 files changed, 0 insertions(+), 0 deletions(-)\n rename subrep/subrep/anotherfile => anotherfile (100%)\n delete mode 100644 subrep/afile\n rename topfile => yetanotherfile (100%)\n\nAnd my top repository looks like\n\n.\n├── anotherfile\n└── yetanotherfile\n\nThe issue seems to be related to the subdirectory \"subrep\" of my\nrepository \"surep\" having the same name - if i rename it to something\nelse everything works as expected.\n\nI could reproduce this behaviour in git 2.12.0 and the current next\nbranch (v2.13.0-303-g4ebf30216)\n\nThanks,\nNikolai\n"}]}