TL;DR
To verify that git LFS is working correctly, add the file(s) and run either "git lfs status" or "git lfs ls-files" to ensure the files appear with the LFS value in parenthesis. After running "git lfs track", refresh the file state by running "git add" before calling "git lfs status" or "git lfs ls-files". Use "git lfs track 'MyProject/Frameworks/**'" for recursive matching. To test, generate .gitattributes with "git lfs track '*.lfs'", create a file Test.lfs in the root directory, and run "git lfs status" to ensure filenames are outputted.
$ git lfs status
On branch master
Git LFS objects to be pushed to origin/master:
Git LFS objects to be committed:
Git LFS objects not staged for commit:
$
git lfs ls-files
: 没有输出
$ git lfs ls-files
$
执行git add Test.lfs
命令。
测试:
$ git lfs status
On branch master
Git LFS objects to be pushed to origin/master:
Git LFS objects to be committed:
Test.lfs (LFS: 2ab9f1e)
Git LFS objects not staged for commit:
$
git lfs ls-files
命令:现在会列出 Test.lfs
。
$ git lfs ls-files
2ab9f1e447 * Test.lfs
$
提交更改。
测试:
$ git lfs status
On branch master
Git LFS objects to be pushed to origin/master:
Test.lfs (2ab9f1e44720efb7a26553e06b667a270320efb3e906553b3f9e0702538a2b3f)
Git LFS objects to be committed:
Git LFS objects not staged for commit:
$
git lfs ls-files
:仍将列出Test.lfs
。
$ git lfs ls-files
2ab9f1e447 * Test.lfs
$
推送更改,包括添加/提交/推送 .gitattributes。
测试:
$ git lfs status
On branch master
Git LFS objects to be pushed to origin/master:
Git LFS objects to be committed:
Git LFS objects not staged for commit:
$
git lfs ls-files
: 继续输出已跟踪的文件
$ git lfs ls-files
2ab9f1e447 * Test.lfs
$
结论:
Git LFS objects not staged for commit
部分似乎是误导性的,因为它从未显示任何文件,即使那些应该由LFS跟踪。
- 如果您尝试使用非git-lfs跟踪的文件进行上一个实验,您也会注意到它错误地出现在
Git LFS objects to be committed
下。 它不是Git LFS对象。 但您可以通过观察其结尾方式来确定它实际上不是Git LFS对象。如果以 (Git: 111111111)
结尾,则不会提交到LFS中。
- 为避免上述混淆,建议您使用
git lfs ls-files
而不是git lfs status
来确定某个内容是否将成为git-lfs的一部分。
- 另一个要注意的问题是,某些应用程序(如Xcode)会以奇怪的方式
git add
文件,导致本应清晰匹配的内容不被视为Git LFS的一部分。 解决方案是取消暂存文件,然后重新暂存它们。
git lfs status
返回的“要推送”的列表中。我注意到在git lfs ls-files
中,所有文件旁边都有相同的哈希值。如果我修改它们并提供新内容,它们将按上述描述进行推送。 - Phil Gilmoregit lfs ls-files
似乎只显示已提交的文件,而git lfs status
则显示暂存的文件。 - Ryan Cargan