与Git分离SVN项目的最佳方式 [英] Best way to fork SVN project with Git

查看:98
本文介绍了与Git分离SVN项目的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Git分叉了一个SVN项目,因为我需要添加他们不想要的功能。但与此同时,我希望能够继续将他们添加到上游版本的功能或修复引入到我的fork中(它们不冲突)。所以,我有我的Git项目与以下分支:


  • master - 我从
  • 实际构建和部署的分支
  • 功能_ *** - 功能分支,我在那里工作或者处理过新事物,然后在完成时合并为主。

  • vendor-svn - 仅限本地的git -svn分支,允许我从他们的svn repo中git svn rebase
  • vendor - 我将vendor-svn合并到的本地分支。然后我推这个(供应商)分支到公共git仓库(github)


  • 因此,我的流程如下所示: p>

      git checkout vendor-svn 
    git svn rebase
    git checkout vendor
    git merge vendor-svn
    git push原始供应商

    现在,问题出现在这里:我需要检查每个提交他们提出了(最好是单独进行,因为在这一点上,我大约有20次提交),然后将它们合并为主。我知道我可以运行 git checkout master; git merge vendor ,但是这会牵扯到所有更改并提交它们,而无法查看它们是否与我需要的相冲突。

    最好的办法是什么? Git似乎是处理项目分叉的好工具,因为您可以从多个回购中拉出和推送 - 我只是没有足够的经验来知道这样做的最佳方式。



    以下是我正在讨论的原始SVN项目: https://appkonference.svn。 sourceforge.net/svnroot/appkonference



    我的分支位于 github.com/jthomerson/AsteriskAudioKonf

    解决方案

    好像你应该创建一个分支主测试:

      git checkout -b测试master 
    git merge vendor-svn
    #test ...
    git checkout master
    git合并测试

    或者,如果您想要测试单个提交,你可以一次将它们全部合并:

      g它签出-b测试master 
    git log --pretty =%H testing ..version-svn |而读取提交;做混帐$ commit ||打破;完成
    #现在检查并测试每个创建的合并

    time:

      git checkout -b测试大师
    git合并$(git log --pretty =%H testing。 .version-svn | tail -n 1)
    #现在测试结果,如果你没事的话......
    #再次运行merge命令合并下一次提交
    git merge $(git log --pretty =%H testing ..version-svn | tail -n 1)
    #等等

    您可能会更喜欢后者,因为您可以在打算合并下一个之前测试该提交。历史将是丑陋的,所以你显然想回去重做一遍,以后再合并。



    无论哪种方式确定并将 rerere.enabled 设置为true,以便git会记住您如何解决冲突,当你回去并重新合并到主人,你不必再解决它们!


    I have forked an SVN project using Git because I needed to add features that they didn't want. But at the same time, I wanted to be able to continue pulling in features or fixes that they added to the upstream version down into my fork (where they don't conflict). So, I have my Git project with the following branches:

    • master - the branch I actually build and deploy from
    • feature_*** - feature branches where I work or have worked on new things, which I then merge to master when complete
    • vendor-svn - my local-only git-svn branch that allows me to "git svn rebase" from their svn repo
    • vendor - my local branch that i merge vendor-svn into. then i push this (vendor) branch to the public git repo (github)

    So, my flow is something like this:

    git checkout vendor-svn
    git svn rebase
    git checkout vendor
    git merge vendor-svn
    git push origin vendor
    

    Now, the question comes here: I need to review each commit that they made (preferably individually since at this point I'm about twenty commits behind them) before merging them into master. I know that I could run git checkout master; git merge vendor, but this would pull in all changes and commit them, without me being able to see if they conflict with what I need.

    So, what's the best way to do this? Git seems like a great tool for handling forks of projects since you can pull and push from multiple repos - I'm just not experienced with it enough to know the best way of doing this.

    Here's the original SVN project I'm talking about: https://appkonference.svn.sourceforge.net/svnroot/appkonference

    My fork is at github.com/jthomerson/AsteriskAudioKonf

    解决方案

    It seems like you should just create a branch off of master for your testing:

    git checkout -b testing master
    git merge vendor-svn
    # test...
    git checkout master
    git merge testing
    

    Or, if you want to test individual commits, you could merge them all individually at once:

    git checkout -b testing master
    git log --pretty=%H testing..version-svn | while read commit; do git merge $commit || break; done
    # now go check out and test each merge that was created
    

    Or one at a time:

    git checkout -b testing master
    git merge $(git log --pretty=%H testing..version-svn | tail -n 1)
    # now test the result, and if you're okay...
    # run the merge command again to merge the next commit
    git merge $(git log --pretty=%H testing..version-svn | tail -n 1)
    # and so on
    

    You'll probably like the latter better, since you can test that commit before bothering to merge the next one. The history will be ugly, so you'd obviously want to go back and redo it all as one merge later.

    Either way be sure and set rerere.enabled to true so that git will remember how you've resolved conflicts, and when you go back and redo the merge straight into master, you won't have to resolve them over again!

    这篇关于与Git分离SVN项目的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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