删除Git lfs链接到文件并直接添加到git

Kat*_* Zz 2 git gitattributes git-lfs

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

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

test/**/*.py filter=lfs diff=lfs merge=lfs -text
Run Code Online (Sandbox Code Playgroud)

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

我尝试过这样的事情:

test/**/*.py !test/my_dir/my_file.py filter=lfs diff=lfs merge=lfs -text
Run Code Online (Sandbox Code Playgroud)

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

rke*_*dge 6

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

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

test/**/*.py           filter=lfs diff=lfs merge=lfs -text
test/my_dir/my_file.py filter=    diff=    merge=    text
Run Code Online (Sandbox Code Playgroud)

然后提交您的.gitattributes文件。

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

test/**/*.py           filter=lfs diff=lfs merge=lfs -text
test/my_dir/my_file.py filter=    diff=    merge=    text
Run Code Online (Sandbox Code Playgroud)