Git: 减少 `.git/lfs/` 的大小

Git: reduce the size of `.git/lfs/`

我使用git-lfs 来跟踪大文件,设置是:

.
├── ...
├── ...
├── large-files
├── ...
├── ...
└── .git

外部存储安装在 large-files 上,所有大文件都放在这里。

此设置的问题是,有一个 .git/lfs 目录,它使用与 large-files 相同数量的磁盘空间,因为我永远不会从 large-files 中删除,并且我的工作树所在的 SSD 的容量小于外部存储,.git/lfs 将超出我的 SSD 的容量。

有没有办法在不将其移动到外部存储的情况下减小此 .git/lfs 的大小? (将 .git 或整个工作树放入外部存储不是一种选择,因为外部存储并不总是可用)

.git/lfsgit-lfs、Git 大文件存储的本地缓存目录。它通过将大文件的历史存储在云存储而不是本地历史中来减小存储库的大小。

.git/lfs不会无限增长。 git-lfs 在那里缓存 "recent" 版本的大文件是正常的。你可以 运行 git lfs prune to have it prune the cache, and you can configure how much it prunes with lfs.pruneoffsetdays and lfs.fetchrecent.

您也可以通过changing lfs.storage将此目录放在别处。