I need to automate an interactive rebase or replace it with other commands. Just let me explain my current situation:
In the svn → git transition, I need to reinstall the newly created git repository in order to fix the “trimming history” made during SVN. Here is my manual workflow to fix the problem.
branchNEW: containing history from SOMEDAY until now branchOLD: containing history from past to SOMEDAY
EDIT or as ascii:
branchNEW: Y - Z branchOLD: W - X
Both branches do not have common commits.
The basic idea is to simply reinstall branchNEW to branchOLD. Unfortunately, there was SOMEDAY refactoring: some files were moved to another directory. The result of the update is that every moved file exists in both places.
EDIT
some file exist in X the (nearly) same files also exist in Y, just on another path branchNEW: W - X - Y - Z (after rebase)
After rebooting, HEAD now contains the X and Y files. I also tried adding a new commit to branchOLD, which removes the old files. After rebooting, SVN-HEAD and git-HEAD are binary identical, but "git log -follow" does not work.
Now to the main problem: I can fix this using a second interactive rebase:
git rebase -i SHA
SHA is the sha-id of the old root commit in branchNEW. Now in the editor I need to change “pick” to “edit” for the topmost commit. After exiting the editor, I now need to delete the wrong files
git rm -f fileA fileB git commit
After that, the HEAD from git is binary, identical to the SVN chapter and, in addition, git has a complete history, and also “git log --follow” works for moved files.
Since this step is only a small part of the huge VCS transition in the future, I need a script to complete the process. But how to automate the above steps?
(I know that the SHA will not remain the same, but I can get the required SHA from svn-id, which is embedded in every commit message)