Okay, so you made a mistake. You thought you should bundle a bunch of your code into a single repository because these disparate apps shared a few libraries and now you're stuck with a swollen monster repo that is a nightmare to deploy from.
(At least... I made this mistake.)
Anyway. You want to split those into multiple repositories and, in the process, regain a shred of your sanity. Let's say you have this repository structure:
monster_repo
│
└───project1
│ │ file011.txt
| |
│ └───subfolder1
│ │ file111.txt
│ │ ...
|
└───project2
| │ file021.txt
| │ ...
|
└───shared_lib
| │ ...
│
└───test
│ │
│ └───project1.tests
| | | ...
| |
│ └───project2.tests
| | ...
|
and you want to separate the two projects. Here's what you're going to do:
-
Clone the repository into whatever you want your subdirectory repo to be called:
git clone https://github.com/you/monster-repo ./project1-repo -
Forget the old repo's history, you're free now:
git remote remove origin git tag | xargs git tag -d git gc --prune=now -
Deploy this ridiculous git incantation that I can't say I fully understand:
git filter-branch --index-filter \ 'git rm --cached -qr --ignore-unmatch -- . && git reset -q $GIT_COMMIT -- project1 test/project1.tests shared_lib' \ --prune-empty -- --all -
Profit (by which I mean deal with all the failing tests now that the directory structure is changed)