Skip to main content

Git Large File Storage

The Git Large File Storage (LFS) client is an extension for versioning large files, such as audio, video, datasets, and graphics.

To run git lfs commands, such as git lfs clone, in Harness CI, use Run steps to install the Git LFS client and run commands.

Requirements

Install the Git LFS client

You can use a Run step to install the Git LFS client into the build workspace.

With self-hosted build infrastructures, if the client is already installed on your host machine, skip to Run git lfs commands.

With Harness Cloud build infrastructure, a version of Git LFS is already installed on Harness Cloud runners. For Harness Cloud image specs, go to Use Harness Cloud build infrastructure. You can use a Run step to install a different version of the Git LFS client if you do not want to use the pre-installed version. Otherwise, skip to Run git lfs commands.

In your CI stage, add a Run step with the following settings:

  • type: Run
  • name: Enter a name for the step, such as install gitlfs.
  • identifier: Enter an ID for the step, such as install_gitlfs.
  • connectorRef and image: Depending on the build infrastructure, you might need to specify a connectorRef, such as a Docker connector, and an image, such as curlimages/curl:7.73.0. For information about when these settings are required and how to specify images, go to Use Run steps.
  • shell: Sh
  • command: Enter commands to get the Git LFS Package Cloud repo and install the package for your platform. For information about these commands, select Install next to the relevant package on the Git LFS Package Cloud repo, or go to the Git LFS documentation on Installing Git LFS.

For example, this step installs Git LFS 3.3.0 on Debian:

              - step:
type: Run
name: install gitlfs
identifier: install_gitlfs
spec:
connectorRef: account.harnessImage ## Specify a container registry connector, if required.
image: curlimages/curl:latest ## Specify an image, if required.
shell: Sh
command: |- ## Use commands for your platform.
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs=3.3.0

Run git lfs commands

These examples show how to use a Run step to run git lfs clone.

git lfs clone commands are formatted as git lfs clone [git clone options] <repository> [<directory>]. It supports the same options as git clone.

For more information about git lfs commands, including git lfs clone, go to the Git LFS documentation.

In your CI stage, add a Run step with the following settings:

  • type: Run
  • name: Enter a name for the step, such as install gitlfs.
  • identifier: Enter an ID for the step, such as install_gitlfs.
  • connectorRef and image: Depending on the build infrastructure, you might need to specify a connectorRef, such as a Docker connector, and an image, such as alpine:latest. For information about when these settings are required and how to specify images, go to Use Run steps.
  • shell: Sh
  • command: Enter your git lfs command as you would on the command line.

For example, this step runs git lfs clone. The connectorRef and image are omitted because they are not required by the build infrastructure.

              - step:
type: Run
name: git lfs clone
identifier: git_lfs_clone
spec:
shell: Sh
command: |-
git lfs clone harness/developer-hub

Run the Pipeline

Save and run your pipeline. While the build runs, you can observe the step logs on the Build details page.