Simple Version:
If I have a branch \"foo-555\", with a bunch of commits with messages like:
Write a script to remove lines with Redmine #555:
#!/bin/sh
mv $1 $1.$$
grep -v 'Redmine #555' < $1.$$ > $1
rm -f $1.$$
Of course you can do that however you want (eg echo a script of commands to ed).
Then launch your rebase with EDITOR set to your script:
EDITOR=/path/to/script git rebase -i REVISION
Of course it still won't be guaranteed to complete -- there may be errors during the rebase caused by leaving out revisions. You can still fix them and git rebase --continue manually.