如何向 git-lfs 跟踪的文件添加过滤器?

问题描述

当前设置

我的存储库初始化为:

git config --local include.path ../.gitconfig

.gitconfig 包含一个过滤器,它使用 sed 删除空行之后的所有行:

[filter "remove-blanks"]
    clean = sed '/^$/Q'

.gitattributes 包含对过滤器的使用:

*.csv filter=remove-blanks

需要更改

我现在需要将文件移动到 lfs,这些文件与应用了过滤器的文件相同。安装和配置lfs后看起来像:

git lfs install
git lfs track *.csv

它使用以下内容更新 .gitattributes:

*.csv filter=lfs diff=lfs merge=lfs -text

解决方案?

有没有办法组合这些过滤器以顺序运行,先运行删除空白,然后运行 ​​lfs?

我还注意到 lfs 安装将以下内容放在用户认主目录中,我可能需要将其添加到存储库的 .gitconfig 中:

[filter "lfs"]
    clean = git-lfs clean --%f
    smudge = git-lfs smudge --%f
    process = git-lfs filter-process
    required = true

我尝试替换第一行来说明类似的内容

    clean = ./myscript.sh

使用 myscript.sh:

#!/bin/sh
sed '/^$/Q'
git-lfs clean -- %f

但这似乎不起作用。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)