tags:

views:

94

answers:

1

Hi,

cloning an svn repository into git is easy with git-svn. However, I need to do it the other way round. I have a git repository lying around and want to import it into an empty (except from trunk, branches and tags folders) keeping all the commit information.

I cerate a git-svn-clone of the svn repo, pulled the git master and dcommitted. However the only commit I have in svn then is the one saying "merged from git"

I also tried the other way: Cloned the git repositoy and called git svn init but git keeps saying "Unable to determine upstream SVN information from HEAD history."

Is it somehow possible to create an svn repository from git?

Cheers, Michael

+2  A: 

when pulling the master branch from the other repo git creates a merge commit, because there is no common history.

you should use git pull --rebase (which will change commit ids, as it recreates the commits) instead, then dcommit


you could also try the following:

checkin the initial version with svn (simply creating those branches, tags, trunk folders and committing) first, then create a git svn clone (git svn -s clone svn://…)

then issue the following commands:

# create a ref to your "svn" commit
git checkout -b svn
# get all your "git" commits
git fetch $your_remote_git_repo
# create a ref to your "git" commit
git branch master FETCH_HEAD
# rebase the rest your git commits
git rebase svn master
# commit to svn!
git svn dcommit

edit cherry pick was only necessary because my quickly set up git repository had only empty commits

knittl
I tried it with git pull --rebase but it destroys the svn upstream information:# git svn clone -s <svn-url># cd project# git pull --rebase git:project# git svn dcommitUnable to determine upstream SVN information from HEAD history.Perhaps the repository is empty. at /usr/lib/git-core/git-svn line 517.
Michael Kowhan
try to create a dummy commit with svn first
knittl
I'm not sure that I understood what you mean: After git svn clone I created a test commit in svn. After git pull --rebase I can still git svn fetch, but not dcommit. I think about just importing into svn ignoring the history.
Michael Kowhan
Thanks for the support. I just made it by pulling the git repository in another branch and cherry-picking all 53 commits into the svn branch (master). Afterwards I was able to git svn dcommit
Michael Kowhan
So what is the correct/preferred solution? There appear to be three options here.
Lachlan