Note in advance: git lfs migrate import --include=\"*.pdf\"
does the job as git lfs ls-files
shows e6521dbea0 - large180m.pdf>
@bk2204's answer says "Your problem is the path you gave to git lfs migrate
import. The path you provide needs to be suitable for a .gitattributes
file, which means it must
be specified in relation to the root of your repository."
That cannot be overstated. Using Git for Windows 2.28.0 I was trying a command like
find . -path ./.git -prune -false -o -size +49M -print0 | xargs -r0t -n1 -I{} git lfs migrate import --everything --verbose --include "{}"
to add all files large enough for Github to complain about to LFS. The command ran and appeared to succeed, history was rewritten, .gitattributes was updated, etc. In fact, .gitattributes was updated correctly.
What wasn't working was the large files weren't being moved into LFS. The problem turned out to be find's output of ./foo/bar/mega.csv
for a path. The git lfs command accepted that, stripped the leading ./
before updating .gitattributes but actually didn't move the file into LFS. Changing to
find . -path ./.git -prune -false -o -size +49M -printf '%P\0' | xargs -r0t -n1 -I{} git lfs migrate import --everything --verbose --include "{}"
made it work.
Posting in the hopes that I save someone else (perhaps future-me) some time and frustration.
Incidentally,
git lfs ls-files
git show HEAD:foo/bar/mega.csv
are helpful in determining if LFS has been set up correctly.