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

左心房为你撑大大i 提交于 2019-12-08 07:27:12

问题


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:


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.



来源:https://stackoverflow.com/questions/49269602/after-using-git-filter-branch-subdirectory-filter-how-do-i-still-use-old-repo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!