Git-lfs 文件存储在哪里?

我正在尝试弄明白如何使用 git-lfs,我使用的是 gitlab EE 服务器。

也许我遗漏了一些东西,但是除了介绍“ track”命令和可爱的1分钟视频的简短教程之外,我找不到任何关于 git-lfs 的文档。

例如,我在一个回购文件中添加并跟踪一个3.7 GB 的 tar 文件,然后推送它:

git lfs track "*.tar"
cp <a folder>/a.tar .
git add a.tar
git commit -m "add a.tar"
git push origin master

问题1 : 在这个过程的最后,a.tar 是否已经上传到了 gitlab 服务器上?目前还不清楚,因为“添加”和“提交”命令需要一些时间(也许不足以让我怀疑3.7 GB 是否在此期间上传) ,但推送根本不需要任何时间(几分之一秒)。

问题2 : 如果文件上传到服务器,在哪里?显然不在回购的同一地方(这就是重点)。我问这个问题是因为我的服务器正在备份,我需要知道 git-lfs 的使用是否需要我以任何方式更新它。

问题3 : 如果文件没有上传,这是否意味着回购的其他用户将获得该文件的链接到添加该文件的原始机器上?有没有办法将其更改为服务器上的某个位置?(回到问题2)

问题4 : 克隆回购后,确实没有完整的3.4 G 文件,“只是”一个文本文件的内容:

version https://git-lfs.github.com/spec/v1
oid sha256:4bd049d85f06029d28bd94eae6da2b6eb69c0b2d25bac8c30ac1b156672c4082
size 3771098624

这当然很棒,这才是重点。但是如果需要访问完整的文件呢?如何下载?

如果能够直接回答这个问题,或者提供一个指向正确文档的链接,我将非常高兴。

30338 次浏览

As explained in this video (at 1:27), when you push a file tracked by git lfs it is intercepted and placed on a different server, leaving a pointer in your git repository. As you see in the reference you provide in Question 4, this worked for you.

This is a bit more tricky. Reading the documentation for git lfs smudge, we have:

Read a Git LFS pointer file from standard input and write the contents of the corresponding large file to standard output. If needed, download the file's contents from the Git LFS endpoint. The argument, if provided, is only used for a progress bar.

The git lfs endpoint can be found from the output of git lfs env. My "endpoint" is a folder under (but not in) my repository, which makes me think that GitLab creates a git repository on the server in our account space to store binary files.

That said, I don't know how you'd go about backing this up. GitHub provides a git lfs server that's "not in a production ready state," so it'd require some work on your part to set it up such that your binary files are uploaded to a server you administer. If backing up these files is a priority and you don't want to use one of the implementations (Amazon S3, etc), you might try another binary file storage system that works with git, such as git-media, git-annex, git-fat, git-bigstore.... I haven't looked into these options in depth, so couldn't make a recommendation.

If the file was not uploaded using git lfs it would have been pushed using git and you'd have a binary file in your git repository. But, yours was uploaded using git lfs as you say in Question 4.

Other users of your repository, after having installed git lfs on their local machines, can simply type git lfs pull to bring in the binary file(s) that you pushed using git lfs.