Cache git-lfs files

We keep all our binary biles in LFS and downloading them each time now takes around 8 minutes. We are trying to work around that by keeping the .git/ directory in caches, which has usability issues with update cycle.

What is the best way to use LFS but not download those each time?

6 Likes

@edzis Did you manage to resolve this issue? I am having a similar problem.

@mjgaylord We are still caching the lfs files and using lfs manually. The essence is in setting the GIT_LFS_SKIP_SMUDGE env variable and updating the cache key for invalidation from time to time. This is visible in the following setup:

version: 2

container: &container
  working_directory: /build
  shell: /bin/bash
  docker:
    - image: IMAGE_URL
      environment:
        GIT_LFS_SKIP_SMUDGE: 1

jobs:
  prepare-and-test:
    <<: *container
    steps:
      - checkout
      - restore_cache:
          keys:
            - gitlfs-{{ .Branch }}-2017_09
            - gitlfs-master-2017_09
      - shell:
          name: Pull Git LFS files, retry until done
          command: |
            while true; do git reset --hard HEAD && git clean -fd && git lfs pull && break; done
      - save_cache:
          key: gitlfs-{{ .Branch }}-2017_09
          paths:
            - .git/lfs

I hope this helps.