Search code examples
gitgit-filter

Why is my git filter not getting invoked?


I'm in a new git repo at ~/repositories/foo. My .gitattributes looks like this:

*.txt   mycrypt

My .git/config looks like this:

[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

I do the following, but my filter never gets invoked (when I list directory ~/temp, I don't see any mycrypt.* files.). Why?

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

Solution

  • The first thing you're missing is to apply the filter. In .gitattributes, instead of:

    *.txt   mycrypt
    

    you want:

    *.txt   filter=mycrypt