views:

44

answers:

2

I am using code from a CVS controlled repository (@sourceforge). Instead of using it directly, I was using a git clone of it made by someone else. In my clone I have several modifications.

In the meantime the upstream project has switched to SVN (@googlecode). I was able to create an automatically updated git clone of that myself.

Now I would like to apply my previous modifications of the CVS/git into the SVN/git. The SHA's are unfortunately different for the same commits.

+1  A: 

Assuming that your patches are in a single linear sequence, you can do this pretty easily using "git format-patch" and "git am". First switch the new repository to the revision from which your changes should sprout and create a new branch to hold your changes:

cd $NEWREPO
git checkout -b my-changes $SPROUT_POINT

Then use "git format-patch" to export the range R1..R2 of commits that you want to migrate and "git am" to apply them in the new repository:

(cd $OLDREPO; git format-patch -k --stdout R1..R2) | (cd $NEWREPO; git am -k)

I recommend first applying the patches to the revision corresponding to the CVS revision from which they originally sprouted, as this should succeed without any conflicts. Then, if necessary, use "git rebase" within the new repository to move the commits to the tip of the appropriate Subversion branch.

mhagger