How to bypass a git clean filter when adding and committing

57 views Asked by At

I have a filter set up to clean certain pieces of metadata and output from a Jupyter Notebook in a git repository. I came across a situation where I wanted to temporarily bypass the filter for a single stage -> commit sequence, and I am wondering if there there is a way to do this more generally (maybe an option in git add or git commit that bypasses the filter?)

I am looking for either a simple way to do this or an explanation of why it is not possible.

Here is what I have considered so far:

1

There are 1 answers

0
ElpieKay On BEST ANSWER

As the clean and smudge commands of a filter driver are specified in configuration files, we can pass temporary values to the variables to overwrite values from configuration files with the help of -c <name>=<value>.

git -c filter.<driver>.clean=foo add
git -c filter.<driver>.clean=foo commit

foo could be empty or maybe cat, so that the file content is unchanged. If you have multiple drivers, use multiple temporary values to disable them all.