Skip to content

git_lfs manages Git Large File Storage — an extension that replaces large binary files with text pointers and stores the actual file contents on a remote server.

git_lfs

ParameterTypeRequiredDefaultDescription
repo_pathstring*Absolute path to the repository
actionstring*LFS operation (see below)
patternsstring[]File patterns for track and untrack (e.g. ["*.psd", "*.zip"])
remotestring"origin"Remote for pull and push
includestringInclude filter for migrate-import / migrate-export
excludestringExclude filter for migrate-import / migrate-export
everythingbooleanfalseWhen true, apply migrate operations to all refs
response_format"markdown" | "json""markdown"Output format

Actions

ActionDescription
installInstall LFS hooks in the repository (run once per clone)
trackRegister file patterns to be stored via LFS. Updates .gitattributes
untrackRemove patterns from LFS tracking
ls-filesList all files currently managed by LFS
statusShow LFS-tracked files that differ between HEAD and the working tree
pullDownload LFS objects from a remote
pushUpload LFS objects to a remote
migrate-importConvert existing files matching a pattern to LFS, rewriting history
migrate-exportConvert LFS-tracked files back to regular Git objects, rewriting history

Examples

Install LFS hooks after cloning:

json
{ "tool": "git_lfs", "params": { "repo_path": "/home/user/myproject", "action": "install" } }

Track design assets and videos:

json
{
  "tool": "git_lfs",
  "params": {
    "repo_path": "/home/user/myproject",
    "action": "track",
    "patterns": ["*.psd", "*.mp4", "*.zip"]
  }
}

List all LFS-tracked files:

json
{ "tool": "git_lfs", "params": { "repo_path": "/home/user/myproject", "action": "ls-files" } }

Pull LFS objects from origin:

json
{ "tool": "git_lfs", "params": { "repo_path": "/home/user/myproject", "action": "pull" } }

Migrate existing *.psd files to LFS (rewrites history):

WARNING

migrate-import rewrites commit history. Only use this on branches that have not been published, or coordinate with all collaborators before pushing the rewritten history.

json
{
  "tool": "git_lfs",
  "params": {
    "repo_path": "/home/user/myproject",
    "action": "migrate-import",
    "include": "*.psd",
    "everything": true
  }
}

Prerequisites

Git LFS must be installed on the system. Verify with:

bash
git lfs version

If LFS is not installed:

  • macOS: brew install git-lfs
  • Ubuntu/Debian: apt install git-lfs
  • Windows: Download from git-lfs.com

After installing, run git lfs install once globally or use git_lfs with action: "install" per repository.

Released under the MIT License.