在使用git filter-branch --subdirectory-filter后,我仍然如何使用旧回购和回收git空间? [英] After using git filter-branch --subdirectory-filter how do I still use old repo and reclaim git space?

查看:398
本文介绍了在使用git filter-branch --subdirectory-filter后,我仍然如何使用旧回购和回收git空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 git filter-branch 将一个子文件夹拆分成一个新的存储库,参考 https://help.github.com/articles/splitting-a-subfolder-out-into-a-new -repository / https://stackoverflow.com/a/45983384/301513

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

我的问题是,根据文章中的步骤,我需要创建一个新的repo和 git pull the-subdirectory-filter-result

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.

我试过Paul的第5步在 https://stackoverflow.com/a/359759/301513 上回答,但它不起作用。并且 git gc 不会为这些不相关的提交回收git历史记录。

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.

推荐答案

您可以将不需要的历史记录和文件夹归档,然后将文件移动到根目录。这里从git / GitHub的历史记录中删除文件夹及其内容是rm文件夹和文件的几个选项。

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.

这篇关于在使用git filter-branch --subdirectory-filter后,我仍然如何使用旧回购和回收git空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆