如何使GIT存储库与SVN同步? [英] How to synchronize a GIT repository with SVN?

查看:159
本文介绍了如何使GIT存储库与SVN同步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算做一个开源项目的分支,但我想切换到GIT。该项目使用SVN,但没有TRAC可用,所以我不能只在我的PC上没有SVN的情况下下载更改集(更不用说svn diff不允许二进制补丁)。



有没有一种方法可以将我的GIT主存储库与SVN的HEAD / trunk同步,而不需要在我的硬盘上保留另一个项目?

解决方案

您可以使用 git-svn同步SVN与Git (1)

如果您有现有的Git存储库,并且想要与另一个SVN存储库绑定,则可以尝试某种巫术,请参阅 http://blog.experimentalworks.net/2009/07/git-voodoo/

该博客展示了如何将现有的非git-svn Git存储库转换为使用新创建的远程SVN存储库的git-svn-enabled Git存储库。您可以稍微修改voodoo工作流程,以将现有的SVN存储库导入到Git存储库:
$ b

  • 分支到您现有的Git仓库中

      cd GIT-REPO 
    git svn clone --stdlayout SVN-URL。


  • 设置嫁接:

      TRUNK_HEAD =`git rev-parse trunk` 
    MASTER_INIT =``git rev-list --reverse master |头-1'
    echo $ MASTER_INIT $ TRUNK_HEAD> .git / info / grafts


  • p> Rebase trunk

      git checkout master 
    git rebase --onto trunk v2.0 master


  • 提交至中继线

      git svn dcommit 


  • 提示:通过与git-svn一起使用移植,你应该确保你不会提交 dcommit 空提交。否则, dcommit 将会失败。要过滤空的提交,请尝试

      git filter-branch --prune-empty 

    在第一次之前 dcommit


    I am planning to make a fork of an open-source project, but I want to switch to GIT. The project is using SVN, but there is no TRAC available, so I can't just download changesets without having SVN on my PC (not to mention svn diff doesn't allow binary patches).

    Is there a way to synchronize my GIT master repository with SVN's HEAD/trunk without keeping another project on my HDD?

    解决方案

    You can synchronize SVN with Git using git-svn(1).

    If you have existing Git repository, and want to bind with another SVN repository, you can try some kind of voodoo, see http://blog.experimentalworks.net/2009/07/git-voodoo/.

    The blog shows how to convert existing non-git-svn Git repository, to git-svn-enabled Git repository with a new created remote SVN repository. You can modify the voodoo workflow a little to import an existing SVN repository to you Git repository:

    1. Import the trunk as a parallel branch into your existing Git repository

      cd GIT-REPO
      git svn clone --stdlayout SVN-URL .
      

    2. Setup the graft:

      TRUNK_HEAD=`git rev-parse trunk`
      MASTER_INIT=`git rev-list --reverse master | head -1`
      echo $MASTER_INIT $TRUNK_HEAD >.git/info/grafts
      

    3. Find out the range in master branch to be appended to trunk, for example, only the changes start from tag v2.0 will be appended to trunk.

    4. Rebase trunk

      git checkout master
      git rebase --onto trunk v2.0 master
      

    5. Commit to trunk

      git svn dcommit
      

    A usage hint: by using grafts with git-svn, you should ensure you won't dcommit empty commits. Otherwise, dcommit will fail. To filter away the empty commits, try

    git filter-branch --prune-empty
    

    before the first time dcommit.

    这篇关于如何使GIT存储库与SVN同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆