We are working with a 3rd party PHP engine that gets regular updates. The releases are kept on a separate branch in git, and our fork is the master branch.
This way
I finally managed to solve it.
The answer is:
git filter-branch --tree-filter '~/Scripts/fix-line-endings.sh' -- --all
fix-line-endings.sh contains:
#!/bin/sh
find . -type f -a \( -name '*.tpl' -o -name '*.php' -o -name '*.js' -o -name '*.css' -o -name '*.sh' -o -name '*.txt' -iname '*.html' \) | xargs fromdos
After all line endings were fixed in all trees in all commits, I did an interactive rebase and removed all commits that were fixing line endings.
Now my repo is clean and fresh, ready to be pushed :)
Note to visitors: do not do this if your repo has been pushed / cloned because it will mess things up badly!