git - 如何将单个文件添加到 GIT LFS?

标签 git git-lfs

如何将单个文件添加到 GIT LFS?

大多数示例显示了添加一个模式,该模式指定要添加到 LFS 的文件。但是,我想添加单个文件。例如,如果我这样做

git lfs track "file.bin"

这将跟踪名为 file.bin所有 文件,无论它们位于哪个目录中。

我考虑过向 .gitattributes 添加排除过滤器(! 模式)以排除所有目录,但不支持。

到目前为止,我所做的最好的事情是跟踪我要添加的文件的文件模式,添加文件,然后删除对该文件模式的跟踪。这有点繁琐。有没有更好的办法?

我想表达文件模式 $ROOT_OF_GIT_REPO/file.bin 但缺少表达 $ROOT_OF_GIT_REPO 部分的方法。

最佳答案

使用:

git lfs track --filename [文件路径]

来源:git lfs track --help

--filename

Treat the arguments as literal filenames, not as patterns. Any special glob characters in the filename will be escaped when writing the .gitattributes file.

此选项从 LFS 扩展 (pull request) 的 v2.9.0 开始可用。你可以查看你的本地版本:git lfs version

关于git - 如何将单个文件添加到 GIT LFS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51898857/

相关文章:

git - Git 为哪些类型的二进制文件保留增量?

windows - Git LFS 不考虑 credential.helper 的配置文件级别

git - github SSH 是如何工作的?

git - 如何在我的 git 服务器上获得类似 github 的 ssh 访问行为

混帐狂欢 : Could not open a connection to your authentication agent

git - 涂抹错误 : Smudge Filter LFS Failed during Git Pull

Xcode 服务器持续集成和 git lfs

git - 从 protected github 仓库中获取单个 LFS 文件

git - 在 Docker 中,git-lfs 给出错误 : credentials for https://github. ... 未找到

git - 尝试在 grunt 中获取 git 提交 ID