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
- You are familiar with Git LFS and you have already configured your repos for LFS.
- You have a CI pipeline with a Build stage. If you haven't created a pipeline before, try one of the CI pipeline tutorials or review CI pipeline creation overview.
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.
- Visual
- YAML
In your pipeline's Build stage, add a Run step.
Enter a Name and optional Description.
Depending on the build infrastructure, you might need to specify a Container Registry connector, such as a Docker connector, and an Image, such as
curlimages/curl:latest
. For information about when these settings are required and how to specify images, go to Use Run steps.For Shell, select Sh.
In the Command field, enter commands to 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:
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs=3.3.0For 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.
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: Run
name
: Enter a name for the step, such asinstall gitlfs
.identifier
: Enter an ID for the step, such asinstall_gitlfs
.connectorRef
andimage
: Depending on the build infrastructure, you might need to specify aconnectorRef
, such as a Docker connector, and animage
, such ascurlimages/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.
- Visual
- YAML
In your pipeline's Build stage, add a Run step.
Enter a Name and optional Description.
Depending on the build infrastructure, you might need to specify a Container Registry connector, 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.For Shell, select Sh.
In the Command field, enter your
git lfs
command as you would on the command line.curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs=3.3.0For 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.
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: Run
name
: Enter a name for the step, such asinstall gitlfs
.identifier
: Enter an ID for the step, such asinstall_gitlfs
.connectorRef
andimage
: Depending on the build infrastructure, you might need to specify aconnectorRef
, such as a Docker connector, and animage
, such asalpine:latest
. For information about when these settings are required and how to specify images, go to Use Run steps.shell: Sh
command
: Enter yourgit 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.