Svn -> git migration with several trunk/branches/t

2019-02-14 11:32发布

I have a single SVN repository with the following current structure:

  • project1
    • branches
    • trunk
    • tags
  • project2
    • branches
    • trunk
    • tags

which originally had this structure:

  • project
    • branches
    • trunk
      • proj1
      • proj2
    • tags

That is, the project was split into two separate "subrepositories" (or whatever you want to call that)

Is there any way to migrate this to git without losing history? Would svn2git be better that git-svn for this scenario? Is there any other migration tool?

EDIT: I tried git svn clone as suggested but, as I thought, it didn't follow the move from the old structure to the new one. It only imported the revisions from the new structure.

标签: svn git git-svn
5条回答
Melony?
2楼-- · 2019-02-14 12:08

svn2git just uses "git svn" underneath, so it won't be "better" per se. It just makes nice tags and branches and cleans things up for a clean break from svn. If that's what you want, I'd go ahead and use it on the two sub-repositories individually. It will get all of the appropriate history.

查看更多
做个烂人
3楼-- · 2019-02-14 12:15

First I converted the main trunk to git:

git svn clone url-to-project -s

Then I converted each project:

git svn clone url-to-project1 -s
git svn clone url-to-project2 -s
...

Then for each project I attached the previous history from the main trunk using grafts and filter-branch.

I just blogged about it.

查看更多
孤傲高冷的网名
4楼-- · 2019-02-14 12:16

Your "current" structure already has all the history from the previous structure. So, cloning each project using git svn clone should work fine.

There won't be any need to tell Git about the previous structure with multiple projects under the trunk directory.

The great thing about Git is that you can try the migration as many times as you like until you're satisfied with the outcome.

查看更多
劫难
5楼-- · 2019-02-14 12:17

Did you already try the built-in

git svn clone

git-svn

查看更多
啃猪蹄的小仙女
6楼-- · 2019-02-14 12:20

Use git svn clone -s SVN_REPOS to have git clone the Subversion repository assuming a standard Subversion layout. You will get a local git branch called master, but git branch -a will show you all the remote branches. Subversion branches will just have the branch name, but tags will have a branch name of tags/tag_name.

Don't reuse branch/tag names when cloning locally! git doesn't like that.

This guide helped me a lot.

http://www.viget.com/extend/effectively-using-git-with-subversion/

查看更多
登录 后发表回答