Install git-lfs


Does anyone have a config example to install git-lfs and then do a git lfs pull after code checkout for CircleCI 2.0?

Is git-lfs supported by CircleCI 2.0?

The install steps will depend on the operating system (e.g. the one in the primary container/image if you are using the docker executor type).

We use a custom image based on Alpine Linux and install Git LFS like so in the Dockerfile:

RUN curl -sSL -o /tmp/git-lfs.tgz${GIT_LFS_VERSION}/git-lfs-linux-amd64-${GIT_LFS_VERSION}.tar.gz \
 && echo "${GIT_LFS_HASH}  /tmp/git-lfs.tgz" | sha256sum -c - \
 && tar --strip-components=1 -xzf /tmp/git-lfs.tgz git-lfs-${GIT_LFS_VERSION}/git-lfs -C /usr/local/bin \
 && rm /tmp/git-lfs.tgz \
 && git lfs install

(Note: the double space after echo "${GIT_LFS_HASH} is required for that line to work.)

For Debian based images (or machine executor type running on Ubuntu), something like this should work:

RUN curl -sSL | sudo bash \
 && apt-get update \
 && apt-get install -y git-lfs \
 && rm -rf /var/lib/apt/lists/*

Then in your .circleci/config.yml, we have the following:

      - run:
          name: Git LFS (install Git Large File Storage)
          command: |
            mkdir -p ~/.ssh
            ssh-keyscan -H >> ~/.ssh/known_hosts
            ssh git-lfs-authenticate "${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}" download
            git lfs pull

Of course, if you don’t want to create a custom image you can put all the steps in .circleci/config.yml.