如何克隆/拉取 git 存储库,而忽略 LFS?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42019529/
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 12:35:24  来源:igfitidea点击:

How to clone/pull a git repository, ignoring LFS?

gitgit-lfs

提问by ideasman42

Is there a way to explicitly ignore all git-lfs files on cloneand pull?
(besides uninstalling git-lfswhich I ended up doing).

有没有办法来明确忽略所有的git-LFS文件clonepull
(除了git-lfs我最终做的卸载)。



In this case git-lfs just contains pre-compiled libs for a platform I don't use... so there is absolutely no use in getting them.

在这种情况下,git-lfs 只包含我不使用的平台的预编译库......所以获取它们绝对没有用。

回答by Marcelo ávila de Oliveira

Two alternatives:

两种选择:

1) Using the GIT_LFS_SKIP_SMUDGE variable:

1) 使用 GIT_LFS_SKIP_SMUDGE 变量:

GIT_LFS_SKIP_SMUDGE=1 git clone SERVER-REPOSITORY

2) Configuring the git-lfs smudge:

2) 配置 git-lfs 涂抹:

git config --global filter.lfs.smudge "git-lfs smudge --skip"
git clone SERVER-REPOSITORY

To undo this configuration, execute:

要撤消此配置,请执行:

git config --global filter.lfs.smudge "git-lfs smudge -- %f"

回答by Alija

I'm currently struggling myself to find a clean way to download (and remove afterwards) large files with git-lfs.

我目前正在努力寻找一种干净的方式来下载(然后删除)带有 git-lfs 的大文件。

However, there is a third alternative to the post of @Marcelo ávila de Oliveira:

但是,@Marcelo ávila de Oliveira 的帖子还有第三种选择:

git lfs install --skip-smudge

git lfs install --skip-smudge

will define globally to skip lfs downloads initially, when cloning repositories.

将全局定义为在克隆存储库时最初跳过 lfs 下载。



 

 

EDIT:I've created a tutorial for basic git-lfs handling. Any feedback and suggestions are very welcome.

编辑:我为基本的 git-lfs 处理创建了一个教程。非常欢迎任何反馈和建议。

You can find it at:

您可以在以下位置找到它:

https://sabicalija.github.io/git-lfs-intro/

https://sabicalija.github.io/git-lfs-intro/

or pull it via:

或通过以下方式拉它:

git clone https://github.com/sabicalija/git-lfs-intro.git

git clone https://github.com/sabicalija/git-lfs-intro.git