While it seems like the answer is clearly just what Omar Jackman suggests - and I don't see anything wrong with those steps - it does leave you with a history that may be less than ideal. In particular, I assume if you want the vendor
directory moved to its own repo that some team will work directly with that new repo. If you want them to have full history, there's another step.
That step is to use git filter-branch
with the --subdirectory-filter
. Something along the lines of
git clone path/to/old_repo vendor_repo
cd vendor_repo
git remote remove origin
git filter-branch --subdirectory-filter vendor --prune-empty -- --all
Then validate the results; vendor_repo
should contain a complete history of the changes that occurred in vendor
. If it looks good, you can clean it up. (You probably want to remove the backup refs that filter-branch
creates, the reflog, and the now-unreachable commits that are still cluttering vendor-repo
; re-cloning may be a nice shortcut here.
So now you actually have a repo to use in the 2nd step of Omar's recommended procedure.
You still should probably keep the vendor history in the parent repo as well, because properly substituting the correct submodule commit reference into each historical parent-repo commit doesn't sound at all fun to me. I'm not saying it can't be done; you'd need to capture a map of parent-repo commits to vendor-repo commits and then use that map to drive a --tree-filter
, or something similar. But is there that much to gain from doing it?
Either way, you can easily replace vendor
with the current submodule commit and use the submodule going forward.