Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export git repository to svn

Tags:

git

svn

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

like image 539
Michael Kowhan Avatar asked Aug 09 '10 15:08

Michael Kowhan


People also ask

How do I export a Git repository?

Exporting a Repository Step 1: Go to your git bash. and then to the repo you want to extract or export. Here, we are going to export this repo named 'Ada August-a Challenge' and it's main branch. Step 2: Now export it to your preferred format and location, here we will export it to the same location in .

Can I use Git with SVN?

The git-svn tool is an interface between a local Git repository and a remote SVN repository. Git-svn lets developers write code and create commits locally with Git, then push them up to a central SVN repository with svn commit-style behavior.

How do I clone a local repository in SVN?

# Clone a repo with standard SVN directory layout (like git clone): git svn clone http://svn.example.com/project --stdlayout --prefix svn/ # Or, if the repo uses a non-standard directory layout: git svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/ # View all branches and tags you have ...


2 Answers

Here is my recipe for publishing a git repo via svn:

svn mkdir --parents http://host/path/to/repo/{trunk,tags,branches} \
    -m "Standard layout for $project"
git svn init -s http://host/path/to/repo/
git svn fetch
git rebase trunk master
git svn dcommit

Subversion won't preserve commit times or authorship. God help you if you used branches.

like image 150
Tobu Avatar answered Oct 14 '22 18:10

Tobu


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

like image 37
knittl Avatar answered Oct 14 '22 19:10

knittl