删除Git lfs链接到文件,并将其直接添加到git [英] Remove Git lfs link to file and add it to git directly
问题描述
我需要删除Git LFS文件指针,然后将文件直接添加到Git.
I need to remove a Git LFS file pointer, and add the file directly to Git.
我在.gitattributes中有一个过滤器来匹配某些文件:
I have a filter in .gitattributes to match certain files:
test/**/*.py filter=lfs diff=lfs merge=lfs -text
如何修改它以从该模式中排除1个文件?
How can I modify it to exclude 1 file from this pattern?
我尝试过这样的事情:
test/**/*.py !test/my_dir/my_file.py filter=lfs diff=lfs merge=lfs -text
但是它似乎不起作用... git说没有这样的文件
but it doesn't seem to work... git says that there is no such file
推荐答案
关于优先级,.gitattributes
文件的工作方式与.gitignore
文件类似,但是语法不同.我在任何地方都找不到此文档,但是我已经在本地和GitHub上对其进行了测试.
The .gitattributes
file works similarly to the .gitignore
file regarding precedence, however the syntax is different. I haven't found this documented anywhere, but I've tested it locally and on GitHub.
在为lfs添加模式之后,您可以在其后简单地添加异常,以使您的.gitattributes
文件如下所示:
After you add the pattern for lfs you can simply add the exception after it so that your .gitattributes
file looks like this:
test/**/*.py filter=lfs diff=lfs merge=lfs -text
test/my_dir/my_file.py filter= diff= merge= text
然后提交您的.gitattributes
文件.
这将关闭该文件的lfs过滤器,以后lfs将不会对其进行跟踪.如果文件已经添加到存储库中,请从存储库中删除该文件,然后重新添加.
This turns off the lfs filter for that file and won't be tracked by lfs in the future. If the file is already added to the repository, remove it from the repository and re-add it.
$ git rm --cached test/my_dir/my_file.py
$ git add test/my_dir/my_file.py
$ git commit -m "File removed from lfs"
这篇关于删除Git lfs链接到文件,并将其直接添加到git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!