Why does git lfs migrate not track all pdf files?

后端 未结 2 1148
误落风尘
误落风尘 2021-01-23 07:59

Note in advance: git lfs migrate import --include=\"*.pdf\" does the job as git lfs ls-files shows e6521dbea0 - large180m.pdf

2条回答
  •  迷失自我
    2021-01-23 08:19

    @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.

提交回复
热议问题