On 01/14/2013 01:59 PM, Stefan Schulze wrote:
> I try to rebase our whole history (~1500 commits) onto a quite empty
> branch, only including a single commit (creating the base-directory - so
> there is nothing conflicting in there). [...]
> Can you tell me, where I missed something? If you know any smarter way
> to solve this task, I'd be happy to hear :)

This is more a job for git grafts and "git filter-branch" rather than
"git rebase".

Suppose the SHA1 of the SVN commit that you want as a new base commit is
$NEWROOT and the previous pure-git root commit was $OLDROOT.  First make
a backup of your original repository for safety.  Then create a file
.git/info/grafts containing a single line with the two SHA1s:


(spelled out, of course).  The addition of this file tells git to behave
*as if* $OLDROOT has a single parent, namely $NEWROOT.  This should
already be enough to make your history look the way you want it (e.g.,
when you view the history with gitk).

Now you probably want to rewrite all of your commits to "bake in" the
new ancestry, as grafts are really meant as a temporary measure.  To do
this, use "git filter-branch":

    git filter-branch --tag-name-filter cat --all

When this command has run to completion, you can remove the grafts file
and the history should still look the way you want it.  Once you have
verified the result you can remove the backups of the original branches

    for-each-ref --format="%(refname)" refs/original/ |
        xargs -n 1 git update-ref -d


Michael Haggerty


Reply via email to