How to print a Git LFS file's old version to stdout (git show / git cat-file for LFS)?

前端 未结 3 1473
北海茫月
北海茫月 2020-12-19 09:15

Another title for this question could be \'How to checkout multiple versions of a Git-LFS managed file?\'

I would like to inspect several versions of a file stored i

3条回答
  •  天命终不由人
    2020-12-19 10:12

    Update: @Markonius' answer is the proper way to do it.

    Here is a script that does this based on experimenting with an LFS repository. I didn't look at the LFS protocol in details, so there might be quirks unaccounted for, but it worked for my simple case.

    git-lfs-cat-file

    The relevant details are:

    • LFS files are stored in the index with the following structure:

      version https://git-lfs.github.com/spec/v1
      oid sha256:abcdeffffffffffffff
      size nnnnnnnn
      
    • Actual LFS object will then be under .git/lfs/objects/ab/cd/abcdeffffffffffffff.

提交回复
热议问题