I need to automate a interactive rebase or replace it by other commands. Just let me explain my current situation:
In an svn->git transition i need to rebase the newly created git repository to fix a "history cut-offs" 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 have no common commits.
The basic idea now is to just rebase branchNEW onto branchOLD. Unfortunately there have been some refactoring SOMEDAY: Some files were moved to another directory. The result of the rebase is now, that each 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 the rebase, HEAD now contains the files of X and of Y. I also tried to add a new commit to branchOLD which removes the old files. After the rebase SVN-HEAD and git-HEAD are binary identical, but the "git log --follow" does not work.
Now to the main problem: I am able to fix this by 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 have to change "pick" to "edit" for the topmost commit. After exiting the editor i now have to remove the wrong files
git rm -f fileA fileB
git commit --amend
git rebase --continue
After this HEAD of git is binary identical to head of SVN and in addition, git has the complete history and also "git log --follow" works for the moved files.
As this step is just a small part of a huge VCS transition in the future, i need to script the complete process. But how to automate the above steps?
(i know that SHAs won't stay the same, but i am able to get the required SHA from the svn-id which is embedded in each commit message)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…