简体   繁体   English

使用Git分叉SVN项目的最佳方法

[英]Best way to fork SVN project with Git

I have forked an SVN project using Git because I needed to add features that they didn't want. 我使用Git分叉了一个SVN项目,因为我需要添加他们不想要的功能。 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: 所以,我有我的Git项目与以下分支:

  • master - the branch I actually build and deploy from master - 我实际构建和部署的分支
  • feature_*** - feature branches where I work or have worked on new things, which I then merge to master when complete feature _ *** - 功能分支,我工作或处理新事物,然后在完成时合并为主
  • vendor-svn - my local-only git-svn branch that allows me to "git svn rebase" from their svn repo vendor-svn - 我的本地唯一的git-svn分支,它允许我从他们的svn repo“git svn rebase”
  • vendor - my local branch that i merge vendor-svn into. 供应商 - 我将vendor-svn合并到的本地分支机构。 then i push this (vendor) branch to the public git repo (github) 然后我推动这个(供应商)分支到公共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. 现在,问题出现在这里:我需要检查他们所做的每个提交(最好是单独的,因为此时我在他们后面约有二十个提交) 然后再将它们合并到master中。 I know that I could run git checkout master; 我知道我可以运行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. git merge vendor ,但是这会引入所有更改并提交它们,而我无法看到它们是否与我需要的内容冲突。

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. Git似乎是处理项目分支的一个很好的工具,因为你可以从多个回购中提取和推送 - 我只是没有足够的经验知道这样做的最佳方法。

Here's the original SVN project I'm talking about: https://appkonference.svn.sourceforge.net/svnroot/appkonference 这是我正在谈论的原始SVN项目: https//appkonference.svn.sourceforge.net/svnroot/appkonference

My fork is at github.com/jthomerson/AsteriskAudioKonf 我的分叉是在github.com/jthomerson/AsteriskAudioKonf

It seems like you should just create a branch off of master for your testing: 看起来你应该只为master进行测试创建一个分支:

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! 无论哪种方式都可以确定并将rerere.enabled设置为true,以便git将记住您如何解决冲突,当您返回并重新合并直接进入master时,您将不必再次解决它们!

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

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