git-lfs 文件存储在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34181356/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:37:19  来源:igfitidea点击:

Where are git-lfs files stored?

gitgit-lfs

提问by Vince

I am trying to figure out how to use git-lfs. I use a gitlab EE server.

我想弄清楚如何使用 git-lfs。我使用 gitlab EE 服务器。

Maybe I missed something, but I failed to find any documentation on git-lfs beyond very short tutorial introducing the "track" command and cute 1 minute videos.

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

For example, I add and track a 3.7GB tar file in a repo, and push it:

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

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

Question 1: at the end of this process, has a.tar been uploaded on the gitlab server ? It is unclear as the "add" and the "commit" commands took some time (maybe not long enough to let me wonder if the 3.7GB were uploaded during that time) but the push did not take any time at all (a fraction of second).

问题1:在这个过程结束时,gitlab服务器上有没有上传a.tar?目前尚不清楚“添加”和“提交”命令花费了一些时间(可能时间不够长,让我怀疑是否在此期间上传了 3.7GB)但推送根本不需要任何时间(一小部分)第二)。

Question 2: if the file was uploaded on the server, where ? Obviously not in the same place as the repo (that is the point). I asked because my server is being backed-up, and I need to know if the use of git-lfs requires me to update this in any way.

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

Question 3: if the file was not uploaded, does this mean other users of the repo will get the link to the file on the original machine on which the file was added ? Is there a way to change this to a location on the server ? (back to question 2)

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

Question 4: after cloning the repo, indeed the full 3.4G file is not there, "just" a text file with the content:

问题 4:克隆 repo 后,确实没有完整的 3.4G 文件,“只是”包含以下内容的文本文件:

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

This is of course awesome and the whole point. But what if access to the full file is required ? how to download it ?

这当然很棒,而且是重点。但是如果需要访问完整文件怎么办?如何下载?

I would be happy with either direct answer to this question or a link toward a proper documentation.

我会很高兴直接回答这个问题或提供指向适当文档的链接。

回答by houtanb

Answer 1As explained in this video(at 1:27), when you push a file tracked by git lfsit 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.

答案 1本视频(1:27)中所述,当您推送git lfs它跟踪的文件时,它会被拦截并放置在不同的服务器上,在您的 git 存储库中留下一个指针。正如您在问题 4 中提供的参考资料中看到的,这对您有用。

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

答案 2这有点棘手。阅读 的文档git lfs smudge,我们有:

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.

从标准输入读取一个 Git LFS 指针文件,并将相应大文件的内容写入标准输出。如果需要,请从 Git LFS 端点下载文件的内容。该参数(如果提供)仅用于进度条。

The git lfsendpoint 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.

git lfs终端可以从输出中找到git lfs env。我的“端点”是我的存储库下(但不在)的文件夹,这让我认为 GitLab 在我们帐户空间的服务器上创建了一个 git 存储库来存储二进制文件。

That said, I don't know how you'd go about backing this up. GitHub provides a git lfsserverthat'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.

也就是说,我不知道你会如何支持这一点。GitHub 提供了一个“未处于生产就绪状态”的git lfs服务器,因此您需要做一些工作来设置它,以便将二进制文件上传到您管理的服务器。如果备份这些文件是一个优先事项,并且您不想使用其中一个实现(Amazon S3 等),您可以尝试另一个与 git 一起使用的二进制文件存储系统,例如git-media, git-annex, git-fat, git-bigstore.... 我没有深入研究这些选项,所以无法提出建议。

Answer 3If the file was not uploaded using git lfsit would have been pushed using gitand you'd have a binary file in your git repository. But, yours was uploaded using git lfsas you say in Question 4.

回答 3如果文件不是使用上传的,git lfs它会被推送使用,git并且您的 git 存储库中有一个二进制文件。但是,您的上传是使用git lfs您在问题 4 中所说的。

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

回答 4您的存储库的其他用户,git lfs在他们的本地机器上安装后,可以简单地键入git lfs pull以引入您使用 推送的二进制文件git lfs