Moving a git subtree into different repository

旧巷老猫 提交于 2019-12-05 18:18:24
michas

Alright, reading the source cleared things up.

git subtree add is pretty ugly: It first uses git read-tree to add the current version without any history into the given directory. Afterwards it uses git commit-tree to create a fake merge commit to attach the old history containing the unprefixed files.

On the other hand, now the prefixed file at HEAD and the unprefixed one in HEAD^2 should be exactly the same and should be recognized as a move by --follow.

Unfortuately it is not recognized as such. No idea why.

The best solution is probably to add an explicit commit moving the files to the new directory and do a normal merge. - An alternative is to rewrite the history of the transplanted directory as described in How can I rewrite history so that all files, except the ones I already moved, are in a subdirectory?.

For my situation git subtree add is bad, a normal git merge with a correctly prepared subtree seems to be exactly the right thing.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!