如何迁移到git lfs [英] How to migrate to git lfs

查看:229
本文介绍了如何迁移到git lfs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个git repo,其中许多文件应为lfs,因为它们大于100M.

I have a git repo where many files should be lfs because they are larger than 100M.

环顾四周,我无法找到逐步指南,该指南无法解释如何迁移具有多个分支的实际现有回购协议以及lfs文件在子目录中的位置.

Looking around I was unable to find a step by step guide that explain how to migrate a real existing repo with many branches and where lfs files are within subdirectories.

在我的情况下,大型文件会像这样在回购协议中散布:

In my case large files are spread around the repo like this:

code/track1/file000.pkl
code/track3/dat000.bin
code/track4/pip000.pkl
code/subcode/track5/pip000.pkl
code/subcode/track5/pop000.model

我想仅使用git lfs migrate将git项目转换为git lfs:

I suppose to convert the git project into git lfs just using git lfs migrate:

git lfs install
git lfs migrate import --include="*.pkl"
git lfs migrate import --include="*.bin"
git lfs migrate import --include="*.model"
git commit -m "migrating models"

但这不会做任何事情.

nothing to commit, working tree clean

我要转换所有回购,我的意思是所有文件,历史记录以及所有现有分支.

I want convert all the repo, I mean all the files, the history and also all existing branches.

换句话说,git lfs migrate现在似乎很稳定,但用户却不太喜欢.

In other words, git lfs migrate seems to be stable now but not so user frendly.

运行git lfs track "*.pkl"似乎有效果:

modified:  code/track1/file000.pkl
modified:  code/track4/pip000.pkl
modified:  code/subcode/track5/pip000.pkl

但是下一步该怎么做.我看到git lfs track将开始跟踪已签入到存储库中的新文件或现有文件.

but what to do next. I see that git lfs track will begin tracking a new file or an existing file that is already checked in to your repository.

那历史呢?我之所以努力,是因为我不希望最终得到一个混乱的存储库,而该存储库必须从头开始重新导入,或者必须在哪里处理过滤分支..

But what about the history? I'm struggling because I don't want end up with a messed repository that I have to reimport from scratch or where have to deal with filter-branch..

推荐答案

Git LFS提供了教程有关如何使用git lfs migrate

Git LFS provide a tutorial on how to use git lfs migrate

几件事要提:

  1. 使用lfs迁移时,它会遍历并更改历史记录,这样,当您调用git lfs migrate import --include="*.pkl"时,它将把它添加到要在LFS下跟踪的.gitattributes中,并在整个历史记录中将.pkl文件迁移到LFS .这样,您以后就不需要调用git commit了.请注意,如果您调用git lfs import migration --no-rewrite,它与
  1. When you are using lfs migrate, it goes through and changes the history, such that when you call git lfs migrate import --include="*.pkl", it adds that to the .gitattributes to be tracked under LFS, and migrates .pkl files to LFS throughout your history. As such, you don't need to call git commit afterwards. Note, this would be different if you call git lfs import migrate --no-rewrite, which as the docs indicate leads to a separate commit in which the files are migrated to LFS. (But, given what you've indicated in your question, I don't think that's what you want.)
  2. You indicate that you are working in repo with multiple branches. As such, you might want to use --everything, which the docs indicate includes all local and remote branches in the migration.
  3. If you're unsure as to whether the LFS migration has worked, you can check the lfs directory to see if objects have been moved to LFS storage, or run git lfs ls-files to see which files are currently tracked and stored under LFS. Also, you might want to run the LFS migration with --verbose, which will print out the specific files that have been moved to LFS storage as it progressed through the migration.

这篇关于如何迁移到git lfs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆