Don't automatically download LFS objects (for all users)
jextrevor opened this issue · 11 comments
I've set up Git LFS in a repo I am working on. The repo contains several large files, and several hundred more large files will be added in the future. It is annoying when these files are automatically downloaded as part of git pull.
Is there a config option that I can put in .lfsconfig in our repo that will disable the automatic downloading of LFS files for all users of the repo? Automatic upload is fine, I just want to disable automatic download.
You can set lfs.fetchexclude
to *
:
git-lfs/docs/man/git-lfs-config.5.ronn
Lines 163 to 173 in ac19b5e
Keep in mind, this can be overridden by a local git config change or command line flag. The order of preference for this change is:
.lfsconfig
- User Global Git config
- User local Git config
- Command line flag
Here's the command line flags that git lfs pull
can accept in case they do need some files:
git-lfs/docs/man/git-lfs-pull.1.ronn
Lines 18 to 35 in ac19b5e
Checking this change in .lfsconfig
will ensure that users will not download LFS files by default.
What does this look like in ~/.gitconfig
I currently have the following, and it doesn't seem to work:
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
fetchexclude = *
@thomasbiddle it should look like the following:
[lfs]
fetchexclude = *
(note that [lfs]
!= [filter "lfs"]
).
@ttaylorr That worked - thanks!
If using the mentioned setting in .gitconfig
you then need to use git lfs pull --exclude= --include "filename"
to pull a single file. Took me a while to figure that one out.
Once I've excluded the files, how do I purposely download them in a specific scenario?
You can use git lfs fetch --include="filename" --exclude=""
to override the default include and exclude settings and download the given file. You can also replace filename
with a glob pattern and it will include all files matching that pattern.
hmm that didn't work but
git lfs pull --include="*" --exclude=""
did !
Thank you
How do I go about adding this to .gitattributes
?
When I the recommended above to .gitattributes
and then try a fresh clone I'm getting the following output:
is not a valid attribute name: .gitattributes:30
with line 30 of my .gitattributes
looking as follow:
...
26 *.xlsx filter=lfs diff=lfs merge=lfs -text
27 *.XLSX filter=lfs diff=lfs merge=lfs -text
28 original/* filter=lfs diff=lfs merge=lfs -text
29 [lfs]
30 fetchexclude = *
Any idea why that's happening?
Those values don't go in .gitattributes
. They should live in your local Git configuration file, such as in .git/config
.
Doh. Thanks!