After using git filter-branch --subdirectory-filter how do I still use old repo and reclaim git space?

Refresh

April 2019

Views

83 time

1

I use git filter-branch to split a subfolder out into a new repository, refer to https://help.github.com/articles/splitting-a-subfolder-out-into-a-new-repository/ and https://stackoverflow.com/a/45983384/301513

My question is, according to the steps in the article, I need to create a new repo and git pull the-subdirectory-filter-result into the new repo. But is it possible I can still use old repo and reclaim the git space, i.e to make the old .git only has that subdirectory related metadata? If I can, I don't need to create a new repo, after all the old one does not have much use now.

I tried the step #5 in Paul's answer at https://stackoverflow.com/a/359759/301513, but it did not work. And git gc won't reclaim the git history for those un-related commits.

1 answers

0

You could rm the history and folders you don't want then then move the files to the root. Here Remove folder and its contents from git/GitHub's history are several options to rm folders and files.