For a given project (on which I'm currently working exclusively), I'd like to apply a certain automated conversion on some files. For this discussion, let's assume I want to change line endings from Windows style to Unix style on all text files. I want the new format to be effective as of a certain revision in the past, and carried through the history.
What I usually do is the following: I start an interactive rebase and append the following after each commit starting with the desired starting point:
exec <transformation rule>
exec git commit -m "transform" && git revert --no-edit HEAD
This leads to a transform
followed by a sequence of original commits, each surrounded with revert
and transform
, followed by a final revert
. Then I execute a second interactive rebase and squash all triplets revert
-<original commit>
-transform
, and remove the last revert
. The first transform
stays in place, all other transform
and revert
commits vanish.
This manual process yields (almost) the desired result (I'm not sure about commit dates for the new commits), but I was wondering of it is possible to automate this using filter-branch
, fast-import
or perhaps a custom tool that I have missed in my cursory search.