简体   繁体   English

2个团队的git-svn bridge的常规工作流程

[英]General workflow for git-svn bridge for 2 teams

Lately I read many things about GIT-SVN bridge, tried it myself but somehow I fail when things get rough. 最近,我读了很多有关GIT-SVN桥的东西,我自己尝试了一下,但是当事情变得艰难时,我以某种方式失败了。

The environment We are 2 teams: once uses SVN, the other is rebel and uses GIT. 环境我们有2个团队:一个使用SVN,另一个是反叛者并使用GIT。 In order to sync, I created a bridge between the 2 repos. 为了同步,我在两个仓库之间建立了一座桥梁。 The SVN team has x developers pushing 10 times a day and having mostly a red build, GIT team has 6 developers and they want to fetch only once a week or when they have something to commit so they keep the build mostly green. SVN团队有x个开发人员,一天要推送10次,并且大部分都是红色版本,GIT团队有6个开发人员,他们只想每周获取一次,或者在有东西要提交的时候,只获取一次,以便使构建大部分保持绿色。

Use case: The "bridge" is not automated (yet), therefore it is on my computer so I am responsible to merge branches and dcommit them correctly. 用例: “网桥”不是自动化的(还),因此它在我的计算机上,因此我有责任合并分支并正确地提交它们。 So, the GIT team is splitted in 2: some of them working on branch "branch1" and the rest working on "branch2". 因此,GIT团队分为2个团队:其中一些在“ branch1”分支工作,其余的在“ branch2”分支工作。 They always work in pairs so when "branch1" is done, we create another branch for next task. 它们始终成对工作,因此当完成“ branch1”时,我们将为下一个任务创建另一个分支。

What I tried to do: In order to keep it clear, I created a branch from master called "masterSpace". 我试图做的事情:为了保持清晰,我从master创建了一个分支,称为“ masterSpace”。 I do git-svn rebase on master every morning, then I merge the changes into masterSpace. 我每天早上都在master上做git-svn rebase,然后将更改合并到masterSpace中。 A developer creates from masterSpace "branch1" when needed where devs commit stuff. 在需要开发人员提交内容的地方,开发人员可以从masterSpace“ branch1”创建。 When they are done, I have to commit everything on SVN. 完成后,我必须在SVN上提交所有内容。 I tried like this 我尝试过这样

merge "branch1" into "masterSpace".
checkout master
git svn rebase
git rebase masterSpace
git dcommit
git checkout masterSpace
merge "master" into "masterSpace". 

Then a developer would create a new branch from this masterSpace having everything up-ti-date and the process repeats itself 然后,开发人员将从该masterSpace创建一个新分支,使所有内容都保持最新状态,然后过程重复进行

Problem: I tried this with branches that had a single commit and worked great, but things got rough after like 2 weeks of work ... then my workflow failed. 问题:我在只有一次提交且运行良好的分支上进行了尝试,但经过2个星期的工作后事情变得很艰难……然后我的工作流失败了。 After I decommited , the same commits had different IDs on master and on "masterSpace" so next time I was trying to dcommit I got hell of a lot of conflicts. 取消提交后,相同的提交在master和“ masterSpace”上具有不同的ID,因此下次我尝试取消提交时,遇到了很多冲突。 Even after I merged master into masterSpace. 即使我将master合并到masterSpace之后。 I even tried a simple scenario where: 我什至尝试了一个简单的场景,其中:

 I have a "branchX" with changes
 I merge them on "masterSpace"
 rebase them on master and finally dcommit them.
 Then I made a single change on "masterSpace" 
 I rebased it into "master"

After this, I was like 10 commits ahead (because of the IDs of the previous commits I guess). 在此之后,我就像提前了10次提交(因为我猜为先前提交的ID)。 So...dead end 所以...死胡同

Q1: Solution? Q1:解决方案? What would be the correct workflow for our environment and usecases so that both GIT and SVN teams can sync and work peacefully ? 什么是我们的环境和用例的正确工作流程,以便GIT和SVN团队都可以同步和和平地工作? I decided that the "masterSpace" is redundant and it will never work as I imagined. 我决定“ masterSpace”是多余的,它将无法像我想象的那样工作。 Still, I have to find a fast solution for the dcommits so my team won't lose time or code. 尽管如此,我仍然必须为dcommit找到一个快速的解决方案,这样我的团队才不会浪费时间或代码。 Some helpful information: we change a branch every 2 weeks aprox. 一些有用的信息:我们每2周更改一次分支。 After we finish, we can throw away the used branch and create another one from the master 完成后,我们可以丢弃使用过的分支,并从主分支创建另一个分支。

Q2: How to make everything automatically? 问题2:如何自动制作所有内容? In the near future I plan to move my "bridge" on Jenkins. 在不久的将来,我计划在詹金斯上移动我的“桥梁”。 Would it be possible to find a solution to make it work automatically? 是否有可能找到使它自动运行的解决方案? Something like merging a branch on "jenkinsbranch". 类似于在“ jenkinsbranch”上合并分支。 Jenkins automatically builds this branch, if its green it dcommits it, if not, waits for another push that will fix the build Jenkins自动构建此分支,如果绿色则放弃提交,如果没有,则等待另一次修复构建的推送

In my initial scenario, I planned to have the "masterSpace" as "master" on jenkins. 在我的初始方案中,我计划将jenkins上的“ masterSpace”作为“ master”。 A developer would merge his branch into "masterSpace", jenkins would make a svn-rebase and build it automatically, if it is green then dcommits all the changes. 开发人员会将其分支合并到“ masterSpace”中,詹金斯将创建一个svn-rebase并自动构建它,如果它为绿色,则放弃所有更改。 Else, it waits for a dev to fix the build. 否则,它等待开发人员修复构建。 But... seems like I was wrong. 但是...似乎我错了。

TL:DR What would the normal workflow be when a team works on 2 different branchs for a couple of weeks and wants to dcommit them in SVN (and be in sync with SVN) ? TL:DR如果一个团队在2个不同的分支上工作几个星期并希望在SVN中将其提交(并与SVN同步),那么正常的工作流程是什么?

I have worked in such environment with git-svn and can say that the sync is difficult to make smooth when the rate of changes/conflicts is high both sides. 我曾在git-svn的环境中工作过,可以说当双方的变更/冲突率很高时,很难使同步变得平滑。 In your setup I would try to look whether SubGit is as good as they claim to be. 在您的设置中,我将尝试查看SubGit是否像他们声称的那样好。

If you stick to git-svn, couple of techniques that might potentially make your life easier: 如果您坚持使用git-svn,可能会使用以下两项技术使您的生活更轻松:

  • Try to avoid merges and use rebases everywhere. 尽量避免合并,并在各处使用rebase。 Including working branches. 包括工作分支。 Answering Q3 - do regular rebases of your working branches against your masterSpace or master . 回答第3季度-根据masterSpacemaster定期调整工作分支的masterSpace
  • I would keep your masterSpace separate for convenience of syncing. 为了方便同步,我会将masterSpace分开。 In my case I called it master where the svn branches would use svn prefix, eg svn/trunk . 在我的情况下,我称它为master ,其中svn分支将使用svn前缀,例如svn/trunk Similarly for other mirrored svn branches. 对于其他镜像的svn分支类似。 I will use my naming further. 我将进一步使用我的命名。
  • I wouldn't rebase master onto svn/trunk . 我不会将master svn/trunk Instead I would first rebase changes from svn/trunk onto master , if any. 相反,我会先将svn/trunk更改重新设置为master (如果有)。 At this point I make a technical merge of the svn/trunk into master . 在这一点上,我将svn/trunk技术合并为master The state of these revisions should be equal (you may check git diff svn/trunk master ) so in case you get merge conflicts - just do merge with -s ours , although I think the recent versions of git were smart enough in this case. 这些修订的状态应该是相等的(您可以检查git diff svn/trunk master ),以防万一发生合并冲突-只需与-s ours合并,尽管我认为git的最新版本在这种情况下足够聪明。 Now that master is equal to svn/trunk and git knows about this via the technical merge, I would rebase the changes from the working branch being merged onto the top of master , carry the master to those changes ( git push . HEAD:master ), take a detached HEAD of the resulting master , and do a dcommit to svn/trunk . 现在, master等于svn/trunk和git知道这个通过技术融合,我想变基被合并到顶部从工作分支的变化master ,携带master对这些变化( git push . HEAD:master ) ,从结果master获取一个分离的HEAD,然后对svn/trunk进行dcommit。 At this stage we will get svn/trunk and master again having same contents but different revisions due to svn dcommit. 在这一阶段,我们将再次获得svn/trunkmaster ,它们具有相同的内容,但由于svn dcommit而具有不同的修订版。 Again, I would do a technical merge of svn/trunk to master to mark a point of equality. 再次,我将svn/trunk技术合并到master来标记一个平等点。

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

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