git gc 不会删除 /objects/pack/preserved/ 中的 .old-pack 和 .old-idx 文件

git gc doesn't remove .old-pack and .old-idx files in the /objects/pack/preserved/

我想从 git 存储库中删除垃圾。但是,git gc 命令和 jgit 无助于删除超过 2 年的旧文件,例如./objects/pack/preserved/<sha>.old-pack./objects/pack/preserved/<sha>.old-idx.

我尝试使用以下命令。

$ git gc 
$ git gc --auto 
$ git gc --aggressive 
$ jgit --git-dir=`pwd` gc 
$ jgit --git-dir=`pwd` gc --aggressive

可以使用 gc 的 --prune-preserved 选项通过 jgit 删除文件:

https://git.eclipse.org/c/jgit/jgit.git/commit/?id=91132bb05e767694d35230d515443d54ddc4eff6