6

I have been asked for a school project to submit my work by pushing it to an existing SVN repository. It is an existing repository with some files already there. I have no need for these files or the previous commits.

I have been working on my assignment with a git repository on my. I would like to push my work to the SVN repository without losing any history. How can I do this?

Zameer Manji
  • 3,017
  • 5
  • 31
  • 42
  • Can you explain the history a little more? Have you used `git svn clone` to clone from SVN? – fge Jan 08 '12 at 15:59
  • No not yet. I'm not sure if that is the correct way to approach this problem. So far I have done nothing to fix it. All the guides I see assume I have a bare/new SVN repo. – Zameer Manji Jan 08 '12 at 16:34
  • That is one way, and you are sure not to lose history. But more needs to be known: is your initial git import a copy of the SVN repo at some point? You said you worked on a local git repo, how did you get the files to work with? – fge Jan 08 '12 at 16:37
  • 1
    My git repo is unrelated to my SVN repo. However at the end of the process I would like my SVN repo to be a copy of my git repo. – Zameer Manji Jan 08 '12 at 16:42
  • Ah, you didn't say you had to _create_ an SVN repository, it changes quite a few things... – fge Jan 08 '12 at 16:43
  • 1
    I don't have to create an SVN repo, there is already one to submit to. – Zameer Manji Jan 08 '12 at 16:48
  • 1
    possible duplicate of [Pushing an existing git repository to SVN](http://stackoverflow.com/questions/661018/pushing-an-existing-git-repository-to-svn) – Jeff Jul 20 '15 at 16:58

2 Answers2

8

I would do a mix. That is, first clone the svn with git svn. Then in this new repository, you merge your work from your current git repository.

$ git svn clone http://svn.example.com/project/trunk
$ cd trunk
$ git checkout -b mywork
$ git pull /path/to/current/work/repository/.git master

Now you have your work in the mywork branch in the clone from subversion. Time to merge and push.

$ git checkout master
$ git merge mywork
$ git svn dcommit

Enjoy!

0

You can, as a pre-requisite ensure that all your changes in git have been applied or merged into the master branch.

Then you can run git-svn rebase to merge any updates from svn and finally git-svn dcommit to commit changes.

There is a detailed explanation here - cf - http://www.viget.com/extend/effectively-using-git-with-subversion/

First Zero
  • 21,586
  • 6
  • 46
  • 45