代码之家  ›  专栏  ›  技术社区  ›  rip747

是否将svn repo添加到现有git repo?

  •  42
  • rip747  · 技术社区  · 15 年前

    我知道你可以使用git svn init跟踪svn repo,但是如果你想创建一个全新的repo。

    我的情况是,我目前已经有一个现有的git repo,并希望通过使其成为当前git repo中的远程分支来跟踪SVN repo的主干。

    有什么建议吗?

    5 回复  |  直到 8 年前
        1
  •  22
  •   rip747    15 年前

    经过昨晚的搜索,我终于找到了答案:

    http://i-nz.net/2009/01/15/selective-import-of-svn-branches-into-a-gitgit-svn-repository/

    似乎您必须实际地进入并手动编辑.git/config文件,以便将SVN分支添加到现有的git repo中。所以根据这些说明,我必须为每个分支添加一个条目。

        2
  •  11
  •   Kun Ling    9 年前

    1)在.git/config中定义新的分支:

    [svn-remote "release-branch"]
            url = svn+ssh://xxxx@mono-cvs.ximian.com/source/branches/mono-2-2/mcs
            fetch = :refs/remotes/git-svn-release-branch
    

    2)导入SVN分支。svn_branched_revision是分支在svn中发生时的修订。

    [~]$ git svn fetch release-branch -r SVN_BRANCHED_REVISION
    

    3)将本地Git分支连接到远程分支:

    [~]$ git branch --track release git-svn-release-branch
    

    5)检查和更新

    [~]$ git checkout release
    [~]$ git svn rebase
    
        3
  •  3
  •   Ian Mariano    12 年前

    您可以通过执行以下操作找到svn_branched_修订:

    $ svn log --stop-on-copy PATH_TO_BRANCH
    
        4
  •  3
  •   Community CDub    7 年前

    这个问题的答案( https://stackoverflow.com/a/840411 https://stackoverflow.com/a/7592152 )从Git v1.8.3.2起不再工作( https://stackoverflow.com/a/19833311 )您可以这样做:

    1)在.git/config中定义新的分支:

    [svn-remote "release-branch"]
       url = svn+ssh://xxxx@mono-cvs.ximian.com/source/branches/mono-2-2/mcs
       fetch = :refs/remotes/git-svn-release-branch
    

    2)导入SVN分支。svn_branched_revision是分支在svn中发生时的修订。

    $ git svn fetch release-branch -r SVN_BRANCHED_REVISION
    

    3)创建分支并将本地Git分支连接到远程分支:

    $ git checkout -b release refs/remotes/git-svn-release-branch
    

    5)更新

    $ git svn rebase
    
        5
  •  2
  •   jeffcook2150    15 年前

    这实际上就是git svn init所做的——其他git svn命令只是将事情合并在一起,等等。您可以git svn init和/或复制用git svn clone克隆的svn repo的布局,并且您应该能够拉入本地分支或获取等。在Git SVN的手册页上花点时间,你应该不会有太多的麻烦把一些东西拼凑在一起;如果你这样做了,免费节点上的Git是一个很好的资源。所以,这应该是可能的,没有太多的麻烦,但我不知道如何做这一切。