2

When our GitLab CI/CD job runs, it first pulls a Docker image and then git clones the entire repo. Afterwards, the Build commands are executed in the Docker image, etc.

Is it possible to only clone the non-LFS files from the repo? ... Or perhaps clone the HEAD of the master branch from only a specific subdirectory and it's subdirectories, etc.?

2

Yes, full cloning of LFS files can be restricted! By default, GitLab will clone your repo into the CI/CD build directory. To limit the clone from downloading the LFS files, tell it not to do it. You do this by setting a variable in .gitlab-ci.yml like this.

# Other declarations etc above the specific job
jobname:
  variables:
    GIT_LFS_SKIP_SMUDGE: 1
# More job declarations, etc.

The "smudge" process replaces the link/pointers to the LFS files with the actual files. By telling GitLab's CI job to skip the smudge, the LFS files aren't downloaded.

Placing GIT_LFS_SKIP_SMUDGE: 1 in a variables section at the top may make it apply to all of the defined jobs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.