Main ref: https://mattsch.com/2015/06/19/move-directory-from-one-repository-to-another-preserving-history/
If there are multiple folders, we need to do thing differently.
- Source repo
- git remote rm origin
- git filter-branch --index-filter 'git rm --cached --ignore-unmatch -rf XXX' --prune-empty -f HEAD
- for all other folders or files
- for all subtrees, just do a clean up
- Dest repo
- git remote add <branch> <source repo directory>
- git checkout <branch>
- git checkout <Dest repo working branch>
- git merge develop --allow-unrelated-histories
- git push
- add back subtree
- git push
The assumption is that the directory names in the source repo remain the same in the dest repo. If different, the commit history needs to change.
- Directory name and level manipulation shall be done at the Source repo side. This shall greatly simplify the merge.
No comments:
Post a Comment