markpasc (markpasc) wrote,

Moving commits from git to subversion

It’s fairly well documented what to do if you have a subversion repository and want to develop on it with git. What if you have a project you started in a git repository, but now need to publish it to a subversion repo?

After several attempts and resets, this seems to be what you have to do to check a project you built with local git into an arbitrary place in a subversion repository.

  1. Make a new git repo: mkdir ~/import; cd ~/import; git init
  2. Make the new remote directory in the svn repo: svn mkdir
  3. Link up with the empty path using git-svn: git svn clone -T ''
  4. Add your original repo as a remote: git remote add dev file:///home/username/work/proj
  5. git pull dev master to pull in all the original git repo’s commits.
  6. git svn rebase to rebase all the commits on top of the svn commit.
  7. In my case, the rebase halted on some commits in the git history where I added files. I had to git add the files manually, then git rebase --continue.
  8. git svn dcommit (or with -n to check… but it’s just a list of commit IDs, so it sure didn’t make me feel that much better about doing it)

You can then really check it worked by comparing the subversion content to your git repo:

  1. cp -R ~/work/proj proj-git
  2. rm -r proj-git/.git
  3. svn export proj-svn
  4. diff -rub proj-svn proj-git

As usual in UNIX, silence is golden.

Tags: code, git, subversion
  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened