带有 LFS 的 VSTS - 如何判断它是否真的有效

VSTS with LFS - How to tell if its REALLY working

所以我正在 VSTS 中进行 LFS 的概念验证,但遇到了一个不寻常的问题。我很难证明它正在做它应该做的事情。基本上我按照添加 .gitattributes 文件的说明进行操作

.gitattributes 的内容

*.pdf filter=lfs diff=lfs merge=lfs -text

然后我在根目录添加了一个pdf文件并提交

 git add ./3FOWW_Rules_of_Play_Digital_Final_v1.3.pdf    
 git commit -m "some comment"
 output: [Master_Copy_LFSTest 738f4a6] some comment
 1 file changed, 3 insertions(+)
 create mode 100644 3FOWW_Rules_of_Play_Digital_Final_v1.3.pdf

现在我确实有本地文件 .git\lfs\objects\xx\xx\bunchoftext 确实似乎是我的文件,通过移动和重命名回 pdf 并打开进行测试。

但是在本地仓库根目录中仍然有完整的文件,而不是 3 行指针文件。现在我推送 repo。

  git push origin Master_Copy_LFSTest
  Locking support detected on remote "origin". Consider enabling it with:
  $ git config  

    lfs.https://xxxxxxxx.visualstudio.com/xxxxxx/_git/xxxxx.git/info/lfs.locksverify true
Uploading LFS objects:   0% (0/1), 0 B | 0 B/s                                  
Uploading LFS objects: 100% (1/1), 25 MB | 0 B/s                                
Uploading LFS objects: 100% (1/1), 25 MB | 0 B/s, done
git : To https://xxxxxxx.visualstudio.com/xxxxxxx/_git/xxxxxx
At line:1 char:1
+ git push origin Master_Copy_LFSTest
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (To https://xxxx.../_git/xxxxxx:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

   58a347c..738f4a6  Master_Copy_LFSTest -> Master_Copy_LFSTest

哪种看起来有效,但显然发生了一些事情导致 NotSpecified 错误。

所以它 "seems" 好像有效,但实际上我说不出来。

如果我进入 vsts 分支的代码文件查看器并单击 pdf 文件,它会将二进制文件加载到查看器中,这出乎我的意料,我想我会看到三行指针文件。 这是 show

的输出
git show 738f4a6
commit 738f4a6bc8a87ce34ab2352bb58a0a44c96be48a
Author: Paul <mememe@mememe.com>
Date:   Thu Jul 19 13:53:37 2018 -0400

    some comment

diff --git a/3FOWW_Rules_of_Play_Digital_Final_v1.3.pdf b/3FOWW_Rules_of_Play_Digital_Final_v1.3.pdf
new file mode 100644
index 0000000..4179d33
--- /dev/null
+++ b/3FOWW_Rules_of_Play_Digital_Final_v1.3.pdf
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c7aed7138ea8a2f6eda3e22992a52329d2b945c119a517c02056bf8379b92f36
+size 24590383

    git lfs ls-files
c7aed7138e * 3FOWW_Rules_of_Play_Digital_Final_v1.3.pdf

但真正让我明白的是,如果我进行 VSTS 构建并且在获取源步骤中不选中从 LFS 检出文件的框,我仍然会在输出中获得 pdf 文件(项目之一文件引用它总是复制到输出)。如果这真的有效,我会得到指针文件,而不是真正的 pdf。

这是第二次尝试的命令转储

PM> git lfs track "*.pdf"
Tracking "*.pdf"
PM> git lfs ls-files
PM> git lfs ls-files
PM> git add .
PM> git lfs ls-files
e545334f11 * 1.pdf
PM> git commit -m "added file for lfs"
[master_bugs 3840795] added file for lfs
 1 file changed, 3 insertions(+)
 create mode 100644 1.pdf
PM> git push origin master_bugs
Locking support detected on remote "origin". Consider enabling it with:
  $ git config lfs.https://xxxxxxxxx.visualstudio.com/xxxxxx/_git/xxxxx.git/info/lfs.locksverify true
Uploading LFS objects:   0% (0/1), 0 B | 0 B/s                                  
Uploading LFS objects: 100% (1/1), 2.7 MB | 0 B/s                               
Uploading LFS objects: 100% (1/1), 2.7 MB | 0 B/s, done
git : To https://xxxxxxxx.visualstudio.com/xxxxxxxx/_git/xxxxx
At line:1 char:1
+ git push origin master_bugs
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (To https://xxxx.../_git/xxxxx:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

   7c41bfe..3840795  master_bugs -> master_bugs

PM> git config lfs.https://xxxxxxxx.visualstudio.com/xxxxxxxx/_git/xxxxxxx.git/info/lfs.locksverify true
PM> git push origin master_bugs
git : Everything up-to-date
At line:1 char:1
+ git push origin master_bugs
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Everything up-to-date:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

PM> git push origin master_bugs
git : Everything up-to-date
At line:1 char:1
+ git push origin master_bugs
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Everything up-to-date:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

PM> git show 3840795
commit 3840795646ae042c7d87c34b32ee7235f776f952
Author: Paul <xxxxx@xxxxxxx.com>
Date:   Thu Jul 19 15:58:16 2018 -0400

    added file for lfs

diff --git a/1.pdf b/1.pdf
new file mode 100644
index 0000000..5e46737
--- /dev/null
+++ b/1.pdf
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:e545334f117b7a01e03df7b7d1ba744ff752fdbe28bbfc1178d0a43a95db87cd
+size 2701762
PM> git show 7c41bfe
commit 7c41bfe52faeb8dd4dcb822195c679fc9cb3e4d0
Author: Paul <xxxxx@xxxxxxx.com>
Date:   Thu Jul 19 15:54:11 2018 -0400

    asdsad

diff --git a/.gitattributes b/.gitattributes
index 09d8abc..b634d85 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,3 +1 @@
 *.pdf filter=lfs diff=lfs merge=lfs -text
-"*.pdf" filter=lfs diff=lfs merge=lfs -text
-'*.pdf' filter=lfs diff=lfs merge=lfs -text

我如何判断这是否真的有效?

您的 git 存储库的 pdf 文件 3FOWW_Rules_of_Play_Digital_Final_v1.3.pdf 已经在 Git LFS.

中进行了 管理

正如您通过命令检查的那样:

git lfs ls-files

并且 3FOWW_Rules_of_Play_Digital_Final_v1.3.pdf 文件在提交 738f4a6 中的差异也表明该文件在 git lfs 中管理,如消息所示:

version https://git-lfs.github.com/spec/v1

所以您的主要困惑似乎是为什么即使您在 VSTS 构建获取源步骤中从 LFS 选项中删除select 签出文件也可以看到 lfs 文件。

实际上 LFS 文件的内容不会下载 如果从 LFS 检出文件选项被删除select。您可以通过 lfs 文件的大小.

仔细检查

比如我在 git lfs 中管理了 11.png 文件,当我在获取源步骤中 deselect 从 LFS 选项检出文件时,文件 11.png 是1KB。如果我 select 在获取源步骤中从 LFS 选项检出文件并再次构建,文件 11.png 是 83KB