Git Large File Storage (LFS) is an extension for Git that allows users to manage large files efficiently. The git lfs pull
command is specifically used to download large files tracked by Git LFS from a remote repository to your local machine. This guide provides detailed instructions on how to use git lfs pull
, including pulling specific files, all files, and understanding its interaction with standard git pull operations.
Understanding git lfs pull
Git lfs pull
is used after cloning a repository or to update your current repository with changes from a remote that include updates to LFS objects. It ensures that all files tracked by LFS are downloaded and replaced with their actual content, rather than just pointers.
Basic usage of git lfs pull
Pull all LFS files after cloning: After cloning a repository with LFS files, you typically need to pull these files into your local clone:
Terminalgit lfs pullThis command downloads all LFS-tracked files that are missing or have been updated on the remote.
Pull LFS files from a specific remote: If you are working with multiple remotes, specify which remote to pull from:
Terminalgit lfs pull <remote_name>
Pulling specific LFS files
Sometimes, you may not need all LFS files, especially in large repositories. To pull specific files:
Pull a single file: To pull a specific LFS file, you can use the
git lfs pull
command with a path filter:Terminalgit lfs pull --include="path/to/file"Pull multiple specific files: You can include multiple files by using multiple
--include
flags or by using wildcard characters:Terminalgit lfs pull --include="path/to/file1" --include="path/to/file2"
Advanced options
Recursive pull: In cases where your repository has nested submodules that also use Git LFS, you might want to recursively pull LFS objects for all submodules:
Terminalgit lfs pull --recursiveExclude certain files: If you want to exclude certain files while pulling, use the
--exclude
option:Terminalgit lfs pull --exclude="path/to/unwanted/file"
Interactions with standard git pull
Pulling with LFS during a git pull: When you run a standard
git pull
, Git LFS files are automatically fetched if the Git LFS extension is correctly installed and initialized. However, this only fetches the latest pointers, not the actual file content. A subsequentgit lfs pull
is necessary to download the actual file contents.Pulling without LFS: If you need to perform a
git pull
without fetching LFS objects (for example, to save bandwidth or time), you can temporarily disable LFS:TerminalGIT_LFS_SKIP_SMUDGE=1 git pullLater, you can run
git lfs pull
to download the LFS objects.
For further reading see the official Git LFS documentation.