git lfs迁移有什么作用? [英] What does git lfs migrate do?
问题描述
我认为git lfs migrate
重写了回购的历史记录,以便将指定的大文件保留在LFS中.这意味着存储库应该变小,因为它不直接包含大文件的所有版本.但是,当我跑步
git lfs migrate import --include="test-data/**" --include-ref=refs/heads/master
test-data/
目录中的所有文件都替换为以下文件:
version https://git-lfs.github.com/spec/v1
oid sha256:5853b5a2a95eaca53865df996aee1d911866f754e6089c2fe68875459f44dc55
size 19993296
.git文件夹的大小变为原来的两倍(400MB至800MB).我很迷惑.什么是git lfs migrate doing
?
我做了迁移后干净
git reflog expire --expire-unreachable=now --all
git gc --prune=now
在运行du
之前.之后,这些文件夹将占用大部分空间:
414M .git/objects 398M .git/lfs
唯一的问题是二进制文件的原始git对象仍然位于.git
文件夹中,因为您没有对它们进行垃圾回收. /p>
您应遵循 git lfs迁移指南,其中说明:
上面的方法成功地将先前存在的git对象转换为lfs 对象.但是,常规对象仍保留在.git中 目录.这些将最终由git清理,但要清理 立即将它们运行:
git reflog expire --expire-unreachable=now --all
git gc --prune=now
运行后,您的.git应该具有相同的大小,但是如果您要使用它,则应该看到objects
现在应该比迁移之前小得多,并且lfs
可以容纳其余部分.
更好的消息是,现在其他开发人员/应用程序克隆存储库时,他们只需下载objects
目录,然后仅提取 他们检查的大文件"即可而不是整个历史.
I thought that git lfs migrate
rewrote the history of a repo so that specified large files were kept in LFS. This means that the repo should get smaller, because it doesn't directly contain all versions of large files. However, when I run
git lfs migrate import --include="test-data/**" --include-ref=refs/heads/master
All of the files in the test-data/
directory are replaced with files that look like this:
version https://git-lfs.github.com/spec/v1
oid sha256:5853b5a2a95eaca53865df996aee1d911866f754e6089c2fe68875459f44dc55
size 19993296
And the .git folder becomes twice as large (400MB to 800MB). I am confused. What's git lfs migrate doing
?
Edit: I did clean after migration
git reflog expire --expire-unreachable=now --all
git gc --prune=now
before running du
. Afterwards, most of the space is used by these folders:
414M .git/objects 398M .git/lfs
The only problem is that the original git-objects of the binary files are still in the .git
folder because you didn't garbage-collected them.
You should follow the git lfs migration tutorial which explains:
The above successfully converts pre-existing git objects to lfs objects. However, the regular objects still persist in the .git directory. These will be cleaned up eventually by git, but to clean them up right away, run:
git reflog expire --expire-unreachable=now --all
git gc --prune=now
After running that your .git should be the same size, but if you'll go into it you should see that objects
should be now much smaller than before the migrations and that lfs
holds the rest.
The even better news is that now when other developers/applications clone the repo they will only have to download the objects
directory and will then fetch only the "large-files" which they check out, not the whole history.
这篇关于git lfs迁移有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!