Git Large File Storage
Use Run steps to install Git LFS and run git lfs commands in Harness CI.
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 the commands.
What you will learn in this topic
By the end of this topic, you will learn how to:
Install the Git LFS client in a Run step.
Run
git lfscommands, such asgit lfs clone, in a Run step.View Git LFS logs for a pipeline run.
Before you begin
Before you use Run step to install Git LFS, make sure you have:
Familiarity with Git LFS and repositories that you already configured for LFS.
A CI pipeline with a Build stage.
Install the Git LFS client
Use a Run step to install the Git LFS client into the build workspace.
With self-managed build infrastructures, if the client is already installed on your host machine, go to Run git lfs commands.
With Harness Cloud build infrastructure, Harness Cloud runners already include a version of Git LFS. Go to Use Harness Cloud build infrastructure for Harness Cloud image specs. To use a different version, install it with a Run step. Otherwise, go to Run git lfs commands.
In your pipeline's Build stage, add a Run step.
Enter a Name and an optional Description.
Depending on the build infrastructure, specify a Container Registry connector, such as a Docker connector, and an Image, such as
curlimages/curl:latest. Go to Use Run steps for when these settings are required and how to specify images.For Shell, select Sh.
In the Command field, enter commands that get the Git LFS Package Cloud repo and install the package for your platform. For example, these commands install Git LFS 3.3.0 on Debian:
For information about these commands, select Install next to the relevant package on the Git LFS Package Cloud repo, or go to Installing Git LFS in the Git LFS documentation.
Select Apply Changes to save the step, and then select Save to save the pipeline.
In your CI stage, add a Run step with the following settings:
type: Runname: Enter a name for the step, such asinstall gitlfs.identifier: Enter an ID for the step, such asinstall_gitlfs.connectorRefandimage: Depending on the build infrastructure, specify aconnectorRef, such as a Docker connector, and animage, such ascurlimages/curl:latest. Go to Use Run steps for when these settings are required and how to specify images.shell: Shcommand: Enter commands that 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 Installing Git LFS in the Git LFS documentation.
For example, this step installs Git LFS 3.3.0 on Debian:
Run git lfs commands
Use a Run step to run git lfs commands, such as git lfs clone. The git lfs clone command uses the format git lfs clone [git clone options] <repository> [<directory>] and supports the same options as git clone.
Go to the Git LFS documentation for git lfs commands, including git lfs clone.
In your pipeline's Build stage, add a Run step.
Enter a Name and an optional Description.
Depending on the build infrastructure, specify a Container Registry connector, such as a Docker connector, and an Image, such as
alpine:latest. Go to Use Run steps for when these settings are required and how to specify images.For Shell, select Sh.
In the Command field, enter your
git lfscommand as you would on the command line. For example:Select Apply Changes to save the step, and then select Save to save the pipeline.
In your CI stage, add a Run step with the following settings:
type: Runname: Enter a name for the step, such asgit lfs clone.identifier: Enter an ID for the step, such asgit_lfs_clone.connectorRefandimage: Depending on the build infrastructure, specify aconnectorRef, such as a Docker connector, and animage, such asalpine:latest. Go to Use Run steps for when these settings are required and how to specify images.shell: Shcommand: Enter yourgit lfscommand as you would on the command line.
For example, this step runs git lfs clone. The example omits connectorRef and image because the build infrastructure does not require them.
View Git LFS logs
Save and run your pipeline. While the build runs, you can view the step logs on the Build details page.
Next steps
Configure codebase: Set Download LFS Files to download Git LFS files when the pipeline clones your codebase.
Git Clone step in CI: Clone a repository into the stage's workspace.
Last updated
Was this helpful?