为什么我的 git 过滤器没有被调用?

Why is my git filter not getting invoked?

我在 ~/repositories/foo 的新 git 存储库中。我的 .git 属性如下所示:

*.txt   mycrypt

我的 .git/config 看起来像这样:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[filter "mycrypt"]
    clean = tee /Users/matthew/temp/mycrypt.before.txt | openssl enc -base64 -pass pass:secret | tee /Users/matthew/temp/mycrypt.after.txt

我执行了以下操作,但我的过滤器从未被调用(当我列出目录 ~/temp 时,我没有看到任何 mycrypt.* 文件。)。为什么?

mkdir ~/temp # just for good measure
echo goo > goo.txt
git add goo.txt
git commit -m 'goo'

您缺少的第一件事是应用过滤器。在 .gitattributes 中,而不是:

*.txt   mycrypt

你想要:

*.txt   filter=mycrypt