git subtree merge deletes files in top directory
- From
- Nikolai Hartmann <nikolai.hartmann@gmx.de>
- Date
- May 13, 2017, 09:20 UTC
- Message-ID
- <aa3f2a1c-42d2-06df-9823-c455c798ffb0@gmx.de>
Hi,
I'm trying to add a subtree which contains a folder with the same name as the subtree directory itself. Adding seems to work, but if i pull after the subtree remote changed, files in my top directory are deleted and everything seems to have "moved up" one directory - although i specify a subtree directory with "-P"
For example i start with top repository that contains one file:
. └── topfile
Now i try to add another repository as a subtree which looks like this:
.
├── afile
└── subrep
└── anotherfileRunning `git subtree add -P subrep origin_subrep master --squash` on the top repository produces correctly
. ├── subrep │ ├── afile │ └── subrep │ └── anotherfile └── topfile
Now i change the subrep git by just adding files
.
├── afile
├── bfile
└── subrep
├── anotherfile
└── yetanotherfileWhen i try to merge these into the top repository by `git subtree pull -P subrep origin_subrep master --squash` i get
[...] Removing topfile Removing subrep/subrep/anotherfile Removing subrep/afile Merge made by the 'recursive' strategy. subrep/subrep/anotherfile => anotherfile | 0 subrep/afile | 0 topfile => yetanotherfile | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename subrep/subrep/anotherfile => anotherfile (100%) delete mode 100644 subrep/afile rename topfile => yetanotherfile (100%)
And my top repository looks like
. ├── anotherfile └── yetanotherfile
The issue seems to be related to the subdirectory "subrep" of my repository "surep" having the same name - if i rename it to something else everything works as expected.
I could reproduce this behaviour in git 2.12.0 and the current next branch (v2.13.0-303-g4ebf30216)
Thanks, Nikolai