Repository navigation
Description
This is a meta issue for the roadmap. Comments should be geared towards the addition and deletion of tasks. Leave detailed discussion to issues linked in tasks. If a task doesn't have an issue next to it, create one and leave a comment here so we can update the list.
Tasks
Prune Command
Deletes objects which fall outside retention conditions in order to save disk space on the local clone. Can be invoked specifically (git lfs prune) or via the --prune option on fetch. The following must be retained:
- Objects referenced in the current checkout (required)
- Objects referenced by commits which have not been pushed, either to a named remote, or ANY remote, based on config (required - data only stored locally must never be deleted)
- Other recent objects that you may want to use again without re-downloading (optional)
- Objects referenced at recent branches/tags (current date - N days, configurable, 0 to ignore)
- Objects referenced in other recent commits on HEAD (HEAD commit date - N days, 0 to ignore)
- Objects referenced in other recent commits of recent branches (latest commit - N days, 0 to ignore)
- Take account of
git worktreeto avoid pruning HEAD objects from any referenced worktree
The reason for so many configurable options here is that deleting something too aggressively may result in large downloads which will frustrate the user. The prune command has to be useful enough to be regularly used to keep local storage at a reasonable level, but without annoying the user with repeat downloads if they happen to switch branches or want to look at recent changes. Omitting more options and only keeping the current HEAD + unpushed would probably make a lot of people not use it after they realised they had to re-download other recent branches.
All options should be kept in gitconfig so the user can specify their general preferences for retention and override them for specific repositories if they want. Having them as config options rather than command line options also means they only have to think about them once, making using the command much easier.
Fetch command extensions
Update the fetch command so that it has the following features:
- Fetch objects referenced by a list of refs provided as arguments (currently only 1 supported)
- Fetch objects for the current checkout (no arguments) - as present
- Fetch 'recent' objects in addition to either the list of refs or the current checkout, say via a '--recent' option, which could also be set on by default via gitconfig
- Accept a --prune option to invoke
git lfs pruneafterwards - Accept --all to download all objects ever referenced in the history, for the purposes of migration between remotes. Incompatible with the --prune option.
- Make 'fetch' only download objects, not alter the working copy. Introduce a 'checkout' command to ensure working copy files contain the correct content, and a 'pull' command which combines 'fetch' and 'checkout'.
Where 'recent' objects closely mirrors the prune command's retention periods.
- Initially rename 'fetch' to 'pull'
- Split 'pull' implementation into 2 separate commands, 'fetch' and 'checkout' which can be run separately
- Allow
git lfs fetchto accept multiple refs - Progress reporting on separate
checkoutcommand - Separate
checkoutshould interpret../.\args correctly to filter to current dir - Add a remote as first parameter to
fetchandpullto be specific about where to fetch from - Add new default remote derivation (tracking branch, origin)
- Accept a
--recentoption (always done after named refs or current checkout)- Objects referenced at recent branches/tags (current date - N days, configurable, 0 to ignore)
- Objects referenced in other recent commits on HEAD (HEAD commit date - N days, 0 to ignore)
- Objects referenced in other recent commits of recent branches (latest commit - N days, 0 to ignore)
- Add gitconfig option to always assume --recent when no arguments supplied
- Add a dedicated man page listing all config options
- Accept
--allto download all objects referenced by any reachable commit - Accept a
--pruneoption to trim storage post-fetch
The main purpose of this is to allow users to bulk fetch objects at a time of their choosing, even if they may not have those objects checked out right now. This is useful for running just before travelling, or downloading in the background while you work on other things so that the objects are already there when you come to check out another branch or review a recent change, meaning you don't have to wait.
Include / exclude paths
This feature will allow people to fetch only files in specific paths, or exclude files in specific paths. This is helpful in big repos where a user only needs a subset of the large files to perform their work and would rather not spend the download time or local disk space on any others.
This involves two settings in gitconfig called lfs.include-paths and lfs.exclude-paths, both of which can contain comma-separated lists of relative repository paths, with wildcard matching as in gitignore. If either are specified, they affect the behaviour of git lfs fetch, depending on the path of the file which is referencing the object (in the commit which is being fetched for).
- Add lfs.include-paths and lfs.exclude-paths to config
- In fetch, if include-paths is specified, only file paths which match one or more include-paths items will be fetched
- In fetch, if exclude-paths is specified, file paths which match any exclude-paths items will not be fetched
- This could be extended to prune too at a later date to allow objects to be retrospectively tidied by path to save disk space
Activity
technoweenie commentedon Jul 22, 2015
I'd also like to essentially rename the current
git lfs fetchtogit lfs pull, and then break out a newfetchthat only downloads objects from the LFS server, and a newcheckoutthat only smudges files in the working directory from the local.git/lfs/objectsstorage.I don't think breaking the command up is necessary right away though. I'd be happy with just renaming
fetchtopullfor Git LFS v0.6.x.One other feature that I'd like for the new
git lfs fetchis a way to download everything for a repo for the purposes of migrating LFS servers. I'm assuming if no--recentflag or config is set, thatgit lfs fetch/pullonly downloads the current checkout.rubyist commentedon Jul 23, 2015
👍 to this. In the current implementation of fetch the download and smudge steps are pretty separate in the code so splitting them up will be straight forward.
sinbad commentedon Jul 23, 2015
Ah yes, I forgot to include this, updated. There's one for rename fetch->pull which can be done first to stabilise that interface, and then to add separate fetch & checkout, but I'll probably get them done around the same time anyway.
Good call, added. Your list of command variants was correct (no params = current checkout unless lfs.fetch-recent-always gitconfig setting is enabled), the only thing not on your list was the option to specify 1 or more explicit refs to fetch for (currently only 1 is supported), useful for people wanting to script it.
sinbad commentedon Jul 29, 2015
First PR: #527
technoweenie commentedon Apr 6, 2016
@sinbad: I think all of the prune items are done now too. Can you confirm?
sinbad commentedon Apr 6, 2016
Yep, all the prune items are done, forgot to circle back, sorry.
technoweenie commentedon Apr 6, 2016
🤘
abbiekressner commentedon Mar 28, 2017
Is there any way to accomplish retrospective pruning of excluded paths currently?
ttaylorr commentedon Mar 28, 2017
@abbiekressner not currently, and I don't have this on my immediate roadmap. That being said, I'd be happy to help a contributor looking to get started in working with LFS by offering guidance through opening a pull request.
abbiekressner commentedon Mar 28, 2017
@ttaylorr I would love to help out with this, but I am rather busy at the moment. I may have more time to look into it in a month or so, but I'm a bit of a newbie with actually contributing to projects like this so I would indeed need some guidance on where to start.
ttaylorr commentedon Mar 28, 2017
@abbiekressner that's great! Here a few places you could take a look to get started:
prunecode. There are several goroutines that aggregate different types of objects to prune: stale objects, orphaned objects, and etc. The actualprune()function could be taught to accept a filepathfilter which would filter these results and only prune ones that match a given-Ior-X(include, exclude) flag.fetch,pull, orclone. There's abuildFilepathFilterhelper func in thecommandspackage which would be helpful here as well.abbiekressner commentedon Mar 28, 2017
Great! Thanks, @ttaylorr! I will let you know if I manage to get anywhere with it.
I have one more question for you: Does including an
.lfsconfigfile in the repository withfetchexclude=*in the contents actually do anything? I read somewhere that this will prevent new clones from fetching files, but this did not work for me.ttaylorr commentedon Mar 28, 2017
It does 😄 , but only if you invoke it through
git lfs cloneinstead ofgit clone. This is because those flags are checked from thegit lfs clonecode, but not in thefilter-processcode. This would be another great contribution 👍.abbiekressner commentedon Mar 29, 2017
Thanks for all the quick responses, @ttaylorr! Keep up the great work!