views:

49

answers:

2

Has anyone got a script for git that can go through the history, check out each version, apply a cleanup script, then check the cleaned version into another repository?

I have some code which I've been developing, but I haven't been consistent with code formatting e.g. tabs vs spaces etc. I'd like to rewrite my entire history to be consistent with the new standards.

+4  A: 

git filter-branch does what you need.

For example:

git-filter-branch --tree-filter 'find . -type f | xargs sed -i "s/\t/    /"'

Untested ... but it should do what you want...

But be careful... this transforms the git repository. If somebody has a clone... it will not be connected to your new repo anymore.

jag
+3  A: 

(while technically not an answer).

Please don't modify history. It's there for a reason - for you to learn from it. Don't abuse the power of git.

elcuco