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.
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. You provided an absolute path instead, which told Git LFS to match all the PDF files in a subdirectory called Temp
under a directory in the root of your repository called C:
. Such a directory cannot possibly exist on Windows, but could plausibly exist on a Unix system.
Instead, you want to specify the pattern as simply *.pdf
, which will affect all the PDF files in your repository, wherever they may be located.
In addition, if you have multiple branches, or even if you don't, you usually want to migrate all branches, so you should pass --everything
. So your invocation should look like git lfs migrate import --everything --include="*.pdf"
.