gpt4 book ai didi

git - 从 git repo 永久删除不需要的文件夹 - Repo 大小不变

转载 作者:太空狗 更新时间:2023-10-29 12:47:53 24 4
gpt4 key购买 nike

我有 git 仓库,我不小心将一些库文件提交到 git 远程仓库。

现在它的大小增加了大约 6.23 GB。然后我尝试使用以下命令删除库

git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch node_modules" -- --all

rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now

现在该库已从存储库中删除,并且未在存储库文件夹中列出。但是本地仓库的大小仍然和以前一样大

还有一点就是执行上述命令需要花费大量的时间。我不确定它们是否正常工作

我什至尝试将其推送到远程仓库,

git push --all --force

但是没有成功推送,它尝试到最后一次,突然出现,因为远程仓库无法访问或没有那种响应

我也试过重写标签

git filter-branch -f \ --index-filter 'git rm -r --cached --ignore-unmatch node_modules' \  --tag-name-filter 'cat' -- --all

我还尝试了以下使其工作

git config --global pack.windowMemory 0
git config --global pack.packSizeLimit 0
git config --global pack.threads "3"

但无论我做什么, repo 协议(protocol)的大小仍然是一样的

注:我试过了

git fsck --full --unreachable

列出了几个无法访问的标签

最佳答案

我在 Git pull error: unable to create temporary sha1 filename 中提到仅靠 git gc 是不够的。

应该降低 repo 大小的一个组合应该是:

git gc
git repack -Ad # kills in-pack garbage
git prune # kills loose garbage

但是,这必须在清理大文件 ( git filter-branch ) 之后进行,并且仅适用于本地存储库。

在将 (git push --force) 推送到远程仓库后,远程仓库不会受益于相同的大小缩减。还需要在远程端执行 gc/repack/prune。

if that remote side is TFS... this isn't easy/possible to do for now .

关于git - 从 git repo 永久删除不需要的文件夹 - Repo 大小不变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31308515/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com