git lfs ls-files:星号 (*) 与破折号 (-)

git lfs ls-files : Asterisk (*) vs. Dash (-)

这是我的 git lfs 管理文件列表

$ git lfs ls-files

b1d5dd29dd - file1.zip
27d3073f43 - file2.zip
fb4e699c05 * file3.zip

为什么一个文件旁边有一个 asterisk/star (*),而其他文件旁边有一个破折号 (-)?

git lfs wiki 似乎表明 (*) 是预期的。

https://github.com/github/git-lfs/wiki/Tutorial

git lfs status显示全部清除(无须committed/pushed/staged)。

与git一样,'-'表示工作目录中的文件已被删除。带'-'的两个文件确实被无意中删除了。恢复它们带回了“*”。

让我失望的是 git lfs status 什么也没报告,但我想我理解错了。

这在 the ls-files man page, so I dug into the source code to find the answer 中没有记录。

func lsFilesMarker(p *lfs.WrappedPointer) string {
    info, err := os.Stat(p.Name)
    if err == nil && info.Size() == p.Size {
        return "*"
    }

    return "-"
}

* 可能 表示磁盘上的文件与存储库或索引中的文件大小相同,具体取决于 WrappedPointer.Size 中的内容。 It was added in this commit, but not explained。无论哪种方式,这似乎都是一个糟糕的测试,因为内容可以改变但大小不能改变。

请注意the - code path is never tested. You might wish to let them know缺少测试和文档。

page 建议:

An asterisk (*) after the OID indicates a LFS pointer, a minus (-) a full object.

但我的经历却恰恰相反

对我来说,减号 (-) 表示指针,星号 (*) 表示 git lfs 中的真实 large-file。