Install git-lfs


#1

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?
#2

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:

ENV GIT_LFS_VERSION=2.0.1 \
    GIT_LFS_HASH=e464aa3e13fe47190827960443f1060a814793594a966839c55aa2bbaaf7f752
RUN curl -sSL -o /tmp/git-lfs.tgz https://github.com/git-lfs/git-lfs/releases/download/v${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 https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | 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 github.com >> ~/.ssh/known_hosts
            ssh git@github.com 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.


#3