简体   繁体   English

从svn到git,移动后备箱

[英]From svn to git, with a moved trunk

I'm trying to switch my svn repository to git. 我正在尝试将我的svn存储库切换为git。 It's an old repository, and one of the previous maintainer moved the trunk for each new release. 它是一个旧的存储库,之前的维护者之一为每个新版本移动了主干。 For example, the previous repository was at: 例如,以前的存储库位于:

  • svn+ssh://svn.mycompany.com/project/release_1/trunk SVN + SSH://svn.mycompany.com/project/release_1/trunk

Now, our current trunk is at: 现在,我们目前的主干是:

  • svn+ssh://svn.mycompany.com/project/release_N/trunk SVN + SSH://svn.mycompany.com/project/release_N/trunk

When I checkout the SVN second repository, I've the full history, including before the copy. 当我签出SVN第二个存储库时,我有完整的历史记录,包括复制之前的历史记录。 However when I git-svn the second repository, I don't have the old history (from release_1, ...). 但是,当我git-svn第二个存储库时,我没有旧的历史记录(来自release_1,...)。 The first commit is the copy of release_{N-1} to release_N/trunk . 第一次提交是release_{N-1}release_N/trunk的副本。

Here is what I tried: 这是我尝试过的:

  • git svn clone --no-minimize-url --authors-file my-authors-file svn+ssh://svn.mycompany.com/project/release_N/trunk my_project.git git svn clone --no-minimize-url --authors-file my-authors-file svn + ssh://svn.mycompany.com/project/release_N/trunk my_project.git

Since this does not work, I tried something else. 由于这不起作用,我尝试了别的东西。 Let's assume that the 'copy commit' is K, I tried: 我们假设'复制提交'是K,我尝试过:

  • git svn clone --no-minimize-url -r BASE:K --authors-file my-authors-file svn+ssh://svn.mycompany.com/project/release_N/trunk my_project.git git svn clone --no-minimize-url -r BASE:K --authors-file my-authors-file svn + ssh://svn.mycompany.com/project/release_N/trunk my_project.git

This time git-svn does not find any commit. 这次git-svn找不到任何提交。

Do you know if there is a magic trick to have the full history ? 你知道是否有一个神奇的技巧来拥有完整的历史?

This is what I've understood by the question: 这就是我对这个问题的理解:
You have your history spread across several svn branches (which happen to all be called trunk). 您的历史分布在几个svn分支(这些分支恰好都称为主干)。 You would like all of this history when moving to git. 移动到git时,您会想要所有这些历史记录。

I think the following will fix your problem: 我认为以下内容将解决您的问题:

git svn init my_project.git

git config svn-remote.svn.url svn+ssh://svn.mycompany.com/project
git config svn-remote.svn.fetch release_N/trunk:refs/remotes/trunk
git config svn-remote.svn.branches */trunk:refs/remotes/*
git config svn.authorsfile my-authors-file

git svn fetch

This will create the release_N branch as trunk, and the remaining releases as different branches in your git repository. 这将创建release_N分支作为trunk,其余版本作为git存储库中的不同分支。

As far as I know, you can't get one git svn branch to point at multiple urls, which is what I think you were trying to do. 据我所知,你不能让一个git svn分支指向多个url,这是我认为你试图做的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM