Push an existing git repository to a folder in svn

I have an existing git repository that I've always worked on. But lately I would need to move commits to svn (no need to include all merge, but at least one linear master branch will do)

I'm not very good at git / svn, I'm just a regular user who uses SourceTree and CornerStone or Tortoise with a nice user interface to do my commits, forking and tagging. I've used git -svn before to move the svn repository to git, but never the other way around.

Is it possible? I've searched for several tutorials, but none of them work. I am also not very good at terms like rebase

, reflog

etc., and would be very grateful if there is a good guide for getting simple things without having to learn the more complex git / SVN part. (Simple as I suppose should be people who are facing the same problem and have done it before)

Thanks in advance!

+3


source to share


1 answer


Well, it's actually pretty simple. First you need to clone your svn via git and then add the git repository as another remote. This will give you two seperate ones HEAD

, so you need git-rebase

your git to commit to the git-svn head. There may be conflicts as svn only has linear commits. This is why you need a git command to fix the whole thing before you can finally git svn dcommit

push everything into svn.

Here's a summary:

1. Build a git svn svn clone tracker

git svn clone svn://DEST/repo/projectname/trunk dest

      

We now have a git repository that keeps track of the svn destination for the import operation.

2: Track the git repository we want to import

cd dest
git remote add -f source /path/to/git/source/repo

      

Now, if you check your git history, you will see a whole series of commits from the original git repository and, detached from that, the main HEAD plus git -svn HEAD pointing to the original (one) svn commit we cloned.

3: restart your original git repository with git-svn

Here where the arcane magic lurks. There seem to be many ways to go from here. This was the only one I found to work. Of course, I have tried many ways that have failed. Once I found one that worked, I stopped trying. So if there is a better way I would love to hear it, but it seems to work well.

git rebase --onto remotes/git-svn --root source/master

      



At this point, I realized that my git history was not strictly linear; I have worked on several machines, so the barrel history has been skewed a little.

This meant that what I expected to be a simple operation (which is what you would expect with an SVN hat) required a few fixes to fix bugs along the way:

(
gvim foo # fix merge conflict
git add foo
git rebase --continue
)
# ... rinse and repeat

      

They were required because the branches in the original repo from running on different machines that merged together to form the "original" development backbone were not rebased without a few tweaks.

In general, the conflicts were small and not easy to fix.

4: push up to svn

Now that we've posted everything above with git-svn, this is a simple case:

git svn dcommit

To make changes to svn.

Source: http://goodliffe.blogspot.sg/2011/08/pushing-git-repository-into-existing.html

+6


source







All Articles