I currently have a big git repository that contains many projects, each one in its own subdirectory. I need to split it into individual repositories, each project in its own repo.
I tried git filter-branch --prune-empty --subdirectory-filter PROJECT master
However, many project directories went through several renames in their lives, and git filter-branch does not follow renames, so effectively the extracted repo does not have any history prior to the last rename.
How can I effectively extract a subdirectory from one big git repo, and follow all that directory’s renames back into the past?
Thanks to @Chronial, I was able to cook a script to massage my git repo according to my needs:
Basically what this does is this:
Deletes all files outside of the three directories NAME1, NAME2 or NAME3 that I need (one project was renamed NAME1 -> NAME2 -> NAME3 during its lifetime).
Moves everything inside these three directories to the root of the repository.
I needed to test if “$GIT_INDEX_FILE.new” exists since import of svn into git creates commits without any files (directory-only commits). Needed only if the repo was created with ‘git svn clone’ initially.