How to move a subdirectory between repositories
- git clone https://github.com/carol8fml/old_repo.git (the old repository where the subfolder is)
- cd old_repo
- git filter-branch --subdirectory-filter sub_folder -f (separate subfolder locally)
- git filter-branch -f --tree-filter 'mkdir -v sub_folder; git mv -k * sub_folder' HEAD
- git remote set-url origin https://github.com/carol8fml/new_repo (replace the old url with the url of the new repository)
- git fetch origin
- git pull (if the other repository already has commits)
- git push or git push -f to overwrite