git - 您可以将现有的 git 存储库转换为“blobless”吗?
问题描述
今天,git 提供了“部分克隆”选项,可以下载存储库的提交和树,同时允许按需下载 blob,从而节省网络带宽和磁盘空间。
这可以在初始期间git clone
通过传递来启用--filter=blob:none
。但是,有没有办法将已经存在的本地存储库转换为“blobless”格式?这应该通过删除任何已知可从“promisor”远程获得的本地 blob 来节省一些磁盘空间。
解决方案
虽然我不知道有专门的就地命令,但您仍然可以执行本地克隆,然后将原始文件夹替换为 blobless 副本。(受knittl评论
启发的解决方案)
# If it's your first time, you'd need to enable filtering locally.
git config --global uploadpack.allowFilter true
# Filter your existing repo into a new one.
# The `file://` protocol followed by a full path is required.
git clone --filter=blob:none file:///full_path_to_existing_repo/.git path_to_new_blobless_copy
# Reconfigure the origin of your new repo.
# You can retrieve it with `git remote -v` in your existing repo.
cd path_to_new_blobless_copy
git remote set-url origin remote_path_to_origin.git
cd -
# Replace your existing repo with the new one.
# Destructive operation that will free up the space of the blobs.
# But will also destroy your local stashes, branches and tags that you didn't clone!
rm -rf /full_path_to_existing_repo
mv path_to_new_blobless_copy /full_path_to_existing_repo
推荐阅读
- dji-sdk - [DJI Windows SDK]flightControllerHandler 为空
- mapbox - MapBox - 现有样式的主题更改
- c# - 如何在 C# 中将列表或数组转换为子类型?
- r - ggplot R中两个辅助轴y的两个数据集
- firebase - Firebase 身份验证循环
- java - 如何解析 JSON 嵌套数组
- php - 将列值更新为每行数据
- javascript - 使用本地文件时,如何将参数传递给客户端 HTML 页面?
- c# - C# - 检查泛型类型约束中的编译级别参数| ... 其中 T : new( Foo a )
- shopify - 将产品变量 Shopify 传递给代码段