Converting Git repository into SVN with SubGit
Asked Answered
H

2

8

I am using SubGit to synchronize Git and SVN repos. When cloning a remote Git repo I want to preserve all the history of that repo. The steps I currently follow allow me to copy the history of the master branch only:

svnadmin create svn_repos
subgit-1.0.0-EAP_1381/bin/subgit configure svn_repos
subgit-1.0.0-EAP_1381/bin/subgit install svn_repos
git clone svn_repos gitRepo

cd gitRepo/
git remote add -f newRemote git://127.0.0.1/gitRepo
...
From git://127.0.0.1/gitRepo
 * [new branch]      FirstProductionTag -> newRemote/FirstProductionTag
 * [new branch]      SecondProductionTag -> newRemote/SecondProductionTag
 * [new branch]      ThirdProductionTag -> newRemote/ThirdProductionTag
 * [new branch]      bugfix     -> newRemote/bugfix
 * [new branch]      bugfix2    -> newRemote/bugfix2
 * [new branch]      master     -> newRemote/master

git merge -s ours --no-commit newRemote/master
git read-tree --prefix=foo/bar/ -u newRemote/master 
git commit -m "Merged new Remote into subdirectory /foo/bar"
git push origin master

How can I merge the changes from bugfix and bugfix2 branches at the same time? Thanks!

Helms answered 15/6, 2012 at 9:51 Comment(1)
Evgeniy, what do you think on changing the question title? I think it currently does not reflect the actual issue you had. I'd propose "Converting Git repository into SVN with SubGit" or something like this.Lombroso
L
6

If your goal is to get Subversion repository from remote Git repository and keep both repositories synchronized, consider do the following:

$ svnadmin create svn_repos
$ git clone --mirror git://127.0.0.1/gitRepo svn_repos/.git
$ subgit-1.0.0-EAP_1381/bin/subgit install svn_repos
Lombroso answered 18/6, 2012 at 14:24 Comment(0)
S
0

I logged in to say that vadishev's answer works and is the simplest solution to import a git repo with full history to svn.

I would also like to add that should you require only the master branch to mapped (intentionally omitting the other branches in the git repo), you should first clone the git repo with the single branch flag like so:

git clone git_url --branch git_branch --single-branch target_folder

Thank you vadishev.

Scorecard answered 18/7, 2014 at 2:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.