【问题标题】:How to download a specific git-lfs file into a Docker container如何将特定的 git-lfs 文件下载到 Docker 容器中
【发布时间】:2020-10-30 14:02:02
【问题描述】:

我有一个包含几个大文件的 git 存储库。 Git-LFS 已启用。我想将其中一个文件引入 Docker 容器。我已经在容器中安装了 git-lfs。到目前为止,我有:

RUN git clone --no-checkout --depth 1 https://github.com/my-org/my-data-repo.git
RUN cd my-data-repo
RUN git lfs pull -I data/my-large-file.csv

文件实际上已下载,但 Docker 构建过程失败,因为我收到以下错误:

Error updating the git index: (1/1), 90 MB | 4.8 MB/s                                                                                                                                                                                       
error: data/my-large-file.csv: cannot add to the index - missing --add option?
fatal: Unable to process path data/my-large-file.csv


Errors logged to .git/lfs/logs/20200709T142011.864584.log
Use `git lfs logs last` to view the log.

如何在不抛出异常杀死 Docker 构建过程的情况下做到这一点?

【问题讨论】:

  • 看起来你在打这个:github.com/git-lfs/git-lfs/issues/2937#issuecomment-407024556 如果你使用--no-checkout 标志,那么你不能再拉文件而不破坏 git 的索引
  • 启用 GIT_LFS_SKIP_SMUDGE=1 时,仍然报错:Not in a git repository.
  • 如何启用 GIT_LFS_SKIP_SMUDGE=1?您能否在您的问题中发布显示此内容的更新,它可能会有所帮助

标签: git docker github docker-compose git-lfs


【解决方案1】:

您的一个问题是:

RUN cd my-data-repo
RUN git lfs pull -I data/my-large-file.csv

没有像你期望的那样工作:

  • 启动第一个进程,其中cd my-data-reop 将当前目录设置为my-data-repo
  • 然后结束此过程(连同其工作目录)
  • 然后启动第二个进程,该进程从初始目录运行 git lfs pull ...

您可以对命令进行分组:

RUN cd my-data-repo && git lfs pull -I data/my-large-file.csv

或使用WORKDIR 命令(建议here):

WORKDIR my-data-repo
RUN git lfs pull -I data/my-large-file.csv

【讨论】:

    猜你喜欢
    • 2017-07-24
    • 1970-01-01
    • 1970-01-01
    • 2020-08-30
    • 1970-01-01
    • 2022-10-25
    • 1970-01-01
    • 2020-01-18
    • 2018-08-08
    相关资源
    最近更新 更多