Cleaning Up Unreferenced Files from a Git LFD Repository

Use this command to clean up a Git LFS repository. This command deletes all files from a Git LFS repository in Artifactory that are no longer referenced in a corresponding Git repository.

Commands Params

Parameter

Command / Description

Command name

rt git-lfs-clean

Abbreviation

rt glc

Command options:

--server-id

[Optional]

Server ID configured using the jf config command. If not specified, the default configured server is used.

--refs

[Default: refs/remotes/*] List of comma-separated Git references in the form of "ref1,ref2,..." which should be preserved.

--repo

[Optional]

Local Git LFS repository in Artifactory which should be cleaned. If omitted, the repository is detected from the Git repository.

--quiet

[Default: $CI]

Set to true to skip the delete confirmation message. When running in a CI environment (where the CI environment variable is set), this defaults to true.

--dry-run

[Default: false]

If true, cleanup is only simulated. No files are actually deleted.

--insecure-tls

[Default: false]

Set to true to skip TLS certificates verification.

--retries

[Default: 3]

Number of HTTP retries.

--retry-wait-time

[Default: 0]

Number of seconds or milliseconds to wait between retries. The numeric value should either end with s for seconds or ms for milliseconds (e.g., 10s or 100ms).

Command arguments:

If no arguments are passed in, the command assumes the .git repository is located at current directory.

path to .git

Path to the directory which includes the .git directory.

Cleaning Up Unreferenced Files Examples

Example 1: Clean Up Using the Current Directory

This example cleans up Git LFS files from Artifactory, using the configuration from the .git directory located in the current directory.

jf rt glc

Example 2: Clean Up Using a Specific Path

This example cleans up Git LFS files from Artifactory, using the configuration from the .git directory located inside the path/to/git/config directory.

jf rt glc path/to/git/config

Example 3: Dry Run to Preview Deletions

This example simulates the cleanup without actually deleting any files, allowing you to preview what would be removed.

jf rt glc --dry-run

Example 4: Clean Up with Specific Repository

This example cleans up a specific Git LFS repository in Artifactory.

jf rt glc --repo=my-gitlfs-repo

Example 5: Clean Up with Custom Refs

This example preserves files referenced by HEAD and all remote branches.

jf rt glc --refs=HEAD,refs/remotes/*

Example 6: Quiet Mode for CI/CD Pipelines

This example runs the cleanup without confirmation prompts, suitable for automated pipelines.

jf rt glc --quiet --repo=my-gitlfs-repo

Example 7: With Retry Configuration

This example configures retry behavior for unreliable network connections.

jf rt glc --retries=5 --retry-wait-time=10s