【问题标题】:Remove Git lfs link to file and add it to git directly去掉 Git lfs 链接到文件,直接添加到 git
【发布时间】:2019-12-06 09:38:54
【问题描述】:

我需要删除一个 Git LFS 文件指针,并将该文件直接添加到 Git。

我在 .gitattributes 中有一个过滤器来匹配某些文件:

test/**/*.py filter=lfs diff=lfs merge=lfs -text

如何修改它以从该模式中排除 1 个文件?

我尝试过这样的事情:

test/**/*.py !test/my_dir/my_file.py filter=lfs diff=lfs merge=lfs -text

但它似乎不起作用... git说没有这样的文件

【问题讨论】:

  • 这实际上与从零开始的 Linux 有关,还是与 Git 大文件支持的缩写冲突?
  • Git 大文件支持

标签: git git-lfs gitattributes


【解决方案1】:

.gitattributes 文件在优先级方面与.gitignore 文件的工作方式类似,但语法不同。我还没有在任何地方找到这个文档,但我已经在本地和 GitHub 上对其进行了测试。

为 lfs 添加模式后,您可以简单地在其后添加异常,以便您的 .gitattributes 文件如下所示:

test/**/*.py           filter=lfs diff=lfs merge=lfs -text
test/my_dir/my_file.py filter=    diff=    merge=    text

然后提交您的.gitattributes 文件。

这会关闭该文件的 lfs 过滤器,并且以后不会被 lfs 跟踪。如果文件已添加到存储库,请将其从存储库中删除并重新添加。

$ git rm --cached test/my_dir/my_file.py
$ git add test/my_dir/my_file.py
$ git commit -m "File removed from lfs"

【讨论】:

  • 谢谢)我的决定不同,但我认为它更正确..
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-10-20
  • 1970-01-01
  • 2019-09-19
  • 1970-01-01
  • 1970-01-01
  • 2019-10-29
  • 1970-01-01
相关资源
最近更新 更多