Hi there,

my team works on a project since some months using a central git-repository 
and the work isn't finished. 
Now our customer asked us to deliver our code to their svn after each 
sprint (every three weeks).

In the last four or five days I tried a lot but I have lot's of trouble 
with this task without loosing the history and only commiting single 
snapshots to svn and without the need to do a force-push after each sprint 
to our central git-repo. 

I try to explain my idea of how it could work more in lot's of details, 
what I already tried to do and where I stumbled across problems, I weren't 
able to solve. I think at the end it all results in the one question I 
summarized at the end of this posting.

I created the subproject (directory with trunk/tags/branches) in the 
svn-repository, ran "git checkout -b svn && git svn init https://... && git 
svn fetch && git svn rebase trunk" to initialize my local repository. Now I 
have the following state:
[master] a1->a2->a3->a4->a5
[svn] b1
where "b1" only contains the creation of the "root"-directory.

My plan was, to transfer it to the following state [1]:
[master] a1->a2->a3->a4->a5
[svn] b1->a1'->a2'->a3'->a4'->a5'
[refs/tags/pushedToSvn] a5

In this solution I'wouldn't have to forcibly push the master to origin and 
my teammates can still use their repos.
After the next sprint my repo looks like:
[master] a1->a2->a3->a4->a5->a6->a7
[svn] b1->a1'->a2'->a3'->a4'->a5'
[refs/tags/pushedToSvn] a5

I hoped, I could do something [2] (and move tag) to add the commits 
pushedToMaster..master to the branch "svn":
[master] a1->a2->a3->a4->a5->a6->a7
[svn] b1->a1'->a2'->a3'->a4'->a5'->a6'->a7'
[refs/tags/pushedToSvn] a7

In the thread "Rebasing large commit-set including merges" I asked for the 
first part (moving the history ontop b1) but I think I gave to less 
information of the other circumstances.
So Michael suggested to use git grafts and "git filter-branch" to put b1 
underneath a1. But this gave me - after "git checkout svn && git merge 
--ff-only master" - the following state:
[master] b1->a1'->a2'->a3'->a4'->a5'
[svn] b1->a1'->a2'->a3'->a4'->a5'

After "git dcommit --add-author-from" I get
[master] b1->a1'->a2'->a3'->a4'->a5'
[svn] b1->a1''->a2''->a3''->a4''->a5''
[refs/tags/pushedToSvn] a5'

In this state I can't use our central git-repo anymore without forcibly 
push. Even after doing a force push and my teammates re-cloning their repos 
(and loosing their local branches), I don't know how to continue from this 
point - after the next sprint I have the following state:
[master] b1->a1'->a2'->a3'->a4'->a5'->a6->a7
[svn] b1->a1''->a2''->a3''->a4''->a5''
[refs/tags/pushedToSvn] a5'

How do I move pushedToSvn..master onto the branch "svn"? I think, on this 
point I would need again [2]. 
A simple "git checkout svn && git merge master" expectedly doesn't work, 
because the only common commit 
in both branches is b1. So it results in
[svn] b1->a1''->a2''->a3''->a4''->a5''->a1'->a2'->a3'->a4'->a5'->a6->a7


Who can I move a range of commits (including merge-commits) from one branch 
to another without common base-commits:
[master] a1->a2->a3->a4->a5
[other] a1->b2->b3->b4->b5
[master] a1->a2->a3->a4->a5
[other] a1->b2->b3->b4->b5->a3->a4->a5

After extensively studying the man-page for git-rebase, I thought I could 
do it with rebase somehow similar to [2], but that didn't work...

[1] like "git checkout svn && git cherry-pick a1 && git rebase -p --onto 
svn a1 master"
[2] like "git rebase -p --onto svn pushedToSvn master" - but this does't do 
what I expected... :(


Reply via email to