I want to merge and decouple from a remote repository as subdirectory with full history. There are several ways and questions how to do that.
My first try was to use subtree but it seems not to rewrite the history of the files, so I can't look into the history of the merged repository.
Next try was to manual merge it like Seth Robertson shown up in his answer:
And the trick to making this work: force Git to recognize the rename by creating a subdirectory and moving the contents into it.
mkdir bdir git mv B bdir git commit -a -m bdir-rename
Return to repository "A" and fetch and merge the contents of "B":
cd ../a git remote add -f B ../b git merge -s ours --no-commit B/master git read-tree --prefix= -u B/master git commit -m "subtree merge B into bdir"
To show that they're now merged:
cd bdir echo BBB>>B git commit -a -m BBB
To prove the full history is preserved in a connected chain:
git log --follow B
Works fine so far, but it seems that most tools like doesn't use the follow option for git log
.
So I need another way to do this. Can anyone tell me a way which works without renaming and keeping the history?
Thanks in advance.