Situation
I am putting htm files into git. Then I'm using git diff to compare them. There are differences between the files that I'm not interested in, such as meta or comments tags.
I'm using this approach generally: How to tell git to ignore individual lines, i.e. gitignore for specific lines of code
What I've Done So Far
Here are the steps I've taken:
- Created gitattributes file in
<project root>/.gitattributes
- Added a line defining the files to be filtered:
*.htm filter=gitignore
, i.e. run filter gitignore on all .htm files
- Defined filter in my gitconfig:
$ git config --global filter.gitignore.clean "sed 's/<meta.*>//g'"
, i.e. delete these lines$ git config --global filter.gitignore.smudge cat
, i.e. do nothing when pulling file from repo
- Then I do a diff on an arbitrary file:
git diff A..B -- file.htm > diff.txt
Depending on which branch I'm currently on, I get different results:
- On branch A, I see all meta tags of branch B still, and they appear as additions.
- On branch B, I see all meta tags of branch A still, and they appear as deletions.
The Question
How can I make it so that regardless of which branch I'm on ALL branches get that filter applied to them?