The process is not easy (and you need a "straight" Git repo: no merge, too complex branches and so), and the result is quite raw, but you're still able to convert the main part into SVN. Here are the steps:
- create an empty SVN repository: svn mkdir svn://path/to/repo/project/{trunk,branches,tags}
- clone it in a Git repo: git svn clone svn://path/to/repo/project --stdlayout . This will create a project directory, empty except for the .git information directory; master is the default Git branch created by git-svn that maps SVN trunk.
- cd project
- add the original Git repo as a remote: git remote add origin git://uri/to/git/repo/project.git
- fetch from it: git fetch origin
- create a local branch for the remote master: git checkout -b old_master origin/master . Note that master branch is already present, so we define another one.
- being on old_master we rebase this branch onto master: git rebase --onto master --root . Doing this, we have "moved" all our commits from old_master to master
- and push all the commits into the SVN repo: git svn dcommit
UPDATE: added 'cd project' step 2
16 comments:
hey, out of curiosity why would you want to do this ? Doesn't this go against the decentralization of the Hacker Ethic ( http://en.wikipedia.org/wiki/Hacker_ethic )
good luck!
_J
@James: simply because some teams in Debian uses SVN as VCS and I wanted to import the package history from Git to SVN.
What did you do about the author and date of each commit?
Dear Sir, you are a genius. It might not be elegant but I am glad i found it after breaking my head for the past few hours.
@Chris you can add the --add-author-from option to git svn dcommit to have a From: header added to the svn revisions specifying the original author.
Hi, I cannot reproduce your steps. When i get to the rebase, git prints out a very odd message:
warning: squelched 210 whitespace errors
warning: 215 lines add whitespace errors.
Falling back to patching base and 3-way merge...
error: Your local changes to 'MonitorVendite.BLL/MonitorVendite.BLL.csproj' would be overwritten by merge. Aborting.
Please, commit your changes or stash them before you can merge.
Failed to merge in the changes.
How is it possible to have local changes if I only checked out remote commits?
@GreyFox: please ask this king of question on a user support forum (I don't have time to go deep into you problems and help you)
Guys look at here too...
I'm able to extract git to svn.
BTW initially svn2git and again git2svn.
http://git2svn.blogspot.com/
Awwwww yeaaaahhhh... I've been trying to get this done for a few days now. This is the best and only working solution I found!
Thanks!
How many times can this be done? I need to do this, But I'd like to test it first. Main thing I don't want to do is break the Git repository incase this breaks.
I just needed to do this (don't ask, I'm lucky in my work we have a VCS) and it worked as expected
I've also just had this exact issue ant this looks like it might be working! Thanks for writing this up
Ciao Sandro.
Grazie Mille.
Almost 12 years after you wrote this post, you saved the last few hairs on my head!
Hope you are doing great!
Post a Comment