GIT-LFS-FETCH(1)

πŸ’… GIT-LFS-FETCH(1) β€” the fetch era πŸ’…

okay so bestie, welcome to git-lfs-fetch β€” literally the glow-up command for grabbing all your Git LFS files for a given ref ✨ this is part of the git-lfs(1) suite and it's giving "download all the things" energy πŸŽ€


🌸 NAME 🌸

git-lfs-fetch β€” download all Git LFS files for a given ref, no cap πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

git lfs fetch [options] [<remote> [<ref>...]]
git lfs fetch [options] <remote> --stdin

πŸ‘‘ DESCRIPTION πŸ‘‘

Download Git LFS objects at the given refs from the specified remote. Wondering what happens if you don't specify? See DEFAULT REMOTE and DEFAULT REFS β€” they've got you covered, bestie 🫢

⚠️ important vibe check: this does not update the working copy. it fetches, it doesn't touch your files. periodt πŸ’…

✨ OPTIONS ✨

  • -I <paths>, --include=<paths> β€” specify lfs.fetchinclude just for this invocation; see INCLUDE AND EXCLUDE below πŸ”₯
  • -X <paths>, --exclude=<paths> β€” specify lfs.fetchexclude just for this invocation; see INCLUDE AND EXCLUDE below πŸ”₯
  • -r, --recent β€” download objects referenced by recent branches & commits in addition to those that would otherwise be downloaded. See RECENT CHANGES 🌈
  • -a, --all β€” download all objects referenced by any commit reachable from the refs you passed as arguments. If no refs are provided, then all refs are fetched. This is primarily for backup and migration purposes. Cannot be combined with --recent or --include/--exclude. Ignores any globally configured include and exclude paths to ensure that all objects are downloaded. it's giving "grab everything, we're moving house" πŸ’€
  • --stdin β€” read a list of newline-delimited refs from standard input instead of the command line πŸ“
  • -p, --prune β€” prune old and unreferenced objects after fetching, equivalent to running git lfs prune afterwards. See git-lfs-prune(1) for more details 🧹
  • --refetch β€” also fetch objects that are already present locally. yes, even the ones chilling in your repo already, bestie πŸ™ˆ
  • -d, --dry-run β€” print what would be fetched, without actually fetching anything. the "window shopping" of fetches πŸŽ€
  • -j, --json β€” writes the details of all object transfer requests as JSON to STDOUT, if the command exits successfully. Intended for interoperation with external tools. When --dry-run is also specified, writes the details of the transfers that would occur if the objects were fetched. for the tool girlies πŸ”§βœ¨

πŸŽ€ INCLUDE AND EXCLUDE πŸŽ€

You can configure Git LFS to only fetch objects to satisfy references in certain paths of the repo, and/or to exclude certain paths of the repo, to reduce the time you spend downloading things you do not use. it's called boundaries, bestie πŸ’…

In your Git configuration or in a .lfsconfig file, you may set either or both of lfs.fetchinclude and lfs.fetchexclude to comma-separated lists of paths. If lfs.fetchinclude is defined, Git LFS objects will only be fetched if their path matches one in that list, and if lfs.fetchexclude is defined, Git LFS objects will only be fetched if their path does not match one in that list. Paths are matched using wildcard matching as per gitignore(5).

🌸 note: using the command-line options -I and -X override the respective configuration settings. Setting either option to an empty string clears the value. so you can yeet the config for one command, iconic 🫢

πŸ’– Examples πŸ’–

  • git config lfs.fetchinclude "textures,images/foo*"

This will only fetch objects referenced in paths in the textures folder, and files called foo* in the images folder

  • git config lfs.fetchinclude ".jpg,.png,*.tga"

Only fetch JPG/PNG/TGA files, wherever they are in the repository

  • git config lfs.fetchexclude "media/reallybigfiles"

Don't fetch any LFS objects referenced in the folder media/reallybigfiles, but fetch everything else

  • git config lfs.fetchinclude "media" git config lfs.fetchexclude "media/excessive"

Only fetch LFS objects in the 'media' folder, but exclude those in one of its subfolders


🌈 DEFAULT REMOTE 🌈

Without arguments, fetch downloads from the default remote. The default remote is the same as for git fetch, i.e. based on the remote branch you're tracking first, or origin otherwise. so if you're not sure, just know it'll pick something sensible, slay πŸ’–


⭐ DEFAULT REFS ⭐

If no refs are given as arguments, the currently checked out ref is used. In addition, if enabled, recently changed refs and commits are also included. See RECENT CHANGES for details πŸ‘‘


πŸ”₯ RECENT CHANGES πŸ”₯

If the --recent option is specified, or if the gitconfig option lfs.fetchrecentalways is true, then after the current ref (or those in the arguments) is fetched, we also search for 'recent' changes to fetch objects for, so that it's more convenient to checkout or diff those commits without incurring further downloads.

What changes are considered 'recent' is based on a number of gitconfig options:

  • lfs.fetchrecentrefsdays β€” If non-zero, includes branches which have commits within N days of the current date. Only local refs are included unless lfs.fetchrecentremoterefs is true. The default is 7 days.
  • lfs.fetchrecentremoterefs β€” If true, fetches remote refs (for the remote you're fetching) as well as local refs in the recent window. This is useful to fetch objects for remote branches you might want to check out later. The default is true; if you set this to false, fetching for those branches will only occur when you either check them out (losing the advantage of fetch --recent), or create a tracking local branch separately then fetch again. it's giving "convenience vs. control" πŸ’€
  • lfs.fetchrecentcommitsdays β€” In addition to fetching at branches, also fetches changes made within N days of the latest commit on the branch. This is useful if you're often reviewing recent changes. The default is 0 (no previous changes).
  • lfs.fetchrecentalways β€” Always operate as if --recent was provided on the command line.

🫢 EXAMPLES 🫢

  • Fetch the LFS objects for the current ref from default remote
git lfs fetch
  • Fetch the LFS objects for the current ref AND recent changes from default remote
git lfs fetch --recent
  • Fetch the LFS objects for the current ref from a secondary remote 'upstream'
git lfs fetch upstream
  • Fetch all the LFS objects from the default remote that are referenced by any commit in the main and develop branches
git lfs fetch --all origin main develop
  • Fetch the LFS objects for a branch from origin
git lfs fetch origin mybranch
  • Fetch the LFS objects for 2 branches and a commit from origin
git lfs fetch origin main mybranch
e445b45c1c9c6282614f201b62778e4c0688b5c8

πŸ’œ SEE ALSO πŸ’œ

git-lfs-checkout(1), git-lfs-pull(1), git-lfs-prune(1), gitconfig(5).

Part of the git-lfs(1) suite.


and that's the whole vibe bestie, go forth and fetch iconically πŸ’…βœ¨

this little rewrite was brought to you by Git LFS version vibes, dated the same as ever β€” stay slaying πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from