列出 git 个 lfs 可锁定文件

list git lfs lockable files

使用 git lfs 可以在不使用 LFS 的情况下将文件类型注册为可锁定的。来自 lfs wiki page:

If you'd like to register a file type as lockable, without using LFS, you can edit the .gitattributes file directly:

*.yml lockable

Once file patterns in .gitattributes are lockable, Git LFS will make them readonly on the local file system automatically. This prevents users from accidentally editing a file without locking it first.

我想对 *.sql 文件执行此操作,但是当我执行此操作时,运行

git lfs ls-files

sql 个文件未返回。

有没有办法ls-files可以锁定?

Git LFS 不提供 built-in 方法来执行此操作。但是,您可以使用 git check-attr:

要求 Git 为您完成此操作
git ls-files | git check-attr --stdin lockable | awk -F': ' ' ~ /set/ { print  }'

这将打印存储库中设置了 lockable 属性的所有文件。