问题描述
假设我有一个目录my_dir及其中的一些文件。我有一个子目录my_dir_subdir。文件结构:
my_dir / my_dir_subdir。
如何通过git LFS跟踪my_dir,但不通过git LFS跟踪my_dir / my_dir_subdir /
AFAIK git lfs track会写入到.gitattributes中,然后使用与.gitignore相同的模式匹配规则(请参阅 description),所以我认为(我没有测试过)需要执行: git lfs trackmy_dir / **
git lfs track!my_dir / my_dir_subdir / **
UPDATE:
正如你所发现的,Git LFS不支持像.gitignore那样的负面模式,上面的答案不会像预计。
所以...我认为实现你想要的唯一方法是:
1)对所有子目录使用git lfs track(不同于my_dir_subdir)你要跟踪的是
或者
2)将my_dir_subdir移动到另一个目录
Say I have a directory "my_dir" and some files in it. And I have a subdirectory in it "my_dir_subdir".
File structure:"my_dir/my_dir_subdir".
How to track my_dir via git LFS but not track "my_dir/my_dir_subdir/" via git LFS
AFAIK "git lfs track" does write to .gitattributes, which in turn uses the same pattern matching rules as .gitignore (see the .gitignore PATTERN FORMAT description), so I think (I didn't have tested) you need to execute:
git lfs track "my_dir/**"
git lfs track "!my_dir/my_dir_subdir/**"
UPDATE:
As you've found, Git LFS does not support negative patterns like .gitignore does and the above answer will NOT work as expected.
So... I think the only way to achieve what you want is:
1) Use "git lfs track" for all subdirs (different from my_dir_subdir) you want to track
Or
2) Move my_dir_subdir to another directory
这篇关于跟踪目录中的所有文件以混淆LFS,但忽略该目录中存在的单个文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!