简体   繁体   English

如何构造Git分支

[英]How to structure Git branches

I have to setup git repository for development of software based on preexisting source code of a software vendor. 我必须基于软件供应商的现有源代码设置git存储库来开发软件。 The source code is being periodically updated, I'm looking for most effective approach, I've come up with 2 models of working and I would love to hear your opinion on which one (or maybe another one) would be most effective in my situation. 源代码会定期更新,我正在寻找最有效的方法,我想出了两种工作模式,我很想听听您的意见,即哪种(或另一种)最有效情况。

Overall, there will be 3 completely independent teams each working in their own separate code repositories: A, B, C. 总体而言,将有3个完全独立的团队,每个团队都在各自独立的代码存储库中工作:A,B,C。

Source code repository / team A is where based vendor code exits. 源代码存储库/团队A是基础供应商代码所在的位置。 Source code repository / team B is where based vendor code exits + extensions by 3rd party. 源代码存储库/团队B是基于第三方的供应商代码退出和扩展的地方。 Source code repository / team C the one I'm trying to setup, which should be based on A + B and our own extensions. 我正在尝试设置的源代码存储库/团队C,它应该基于A + B和我们自己的扩展。

Whenever repository A changes, guys from team B will pull it into their repository, integrate and make it available for team C. 每当存储库A发生更改时,来自团队B的人员就会将其拉入其存储库中,进行集成并使其可用于团队C。

Team B may also make independent releases on their own (without any changes from Team A) which they will make available for Team C. B团队也可以自行发布独立发行版(A团队不做任何更改),以供C团队使用。

For team C, I would to setup repository separate branches: 对于团队C,我将设置存储库单独的分支:

master
TeamA
TeamB
develop

Branches TeamA and TeamB will be managed by us (Team C) - we will update them ourselves whenever we receive code from teams A and B and merge them into develop. 分支TeamA和TeamB将由我们管理(团队C)-每当我们从团队A和B收到代码并将它们合并到开发中时,我们都会自己更新它们。

The goal is to be able to understand what is our diff (develop) between TeamA and TeamB (and diff between TeamA and TeamB) and most easily integrate changes from team A and B into develop. 目的是能够了解我们在TeamA和TeamB之间的差异(开发)(以及TeamA和TeamB之间的差异),并且最容易地将团队A和B的更改集成到开发中。

I wonder whether there is any difference regarding if I setup following structure: 我想知道是否设置以下结构是否有任何区别:

1) make all the branches based on master 1)使所有分支都基于母版

master
    TeamA
    TeamB
    develop

or, 2) make following parent-child structure of branches 或2)遵循分支的父子结构

master
    TeamA
        TeamB
            develop

I wonder if it makes any practical difference. 我想知道这是否有实际的区别。

Does anyone had similar situation in the past, what approach would you recommend? 过去有没有人遇到过类似情况,您会推荐哪种方法?

In Git repo, each branch works separately. 在Git仓库中,每个分支都是独立工作的。 So the two structures your provided actually work same with other other. 因此,您提供的两个结构实际上与其他结构相同。 And your branch structure can works for your team (Team C). 而且您的分支机构可以为您的团队工作(团队C)。

And you can also exempt TeamA and TeamB branches in repoC, pull changes from repoA and repoB to develop branch directly: 您还可以免除repoC中的TeamATeamB分支,从repoA和repoB中提取更改以直接develop分支:

git remote add -f teamA <URL for repoA>
git checkout develop
#Use git fetch teamA and git fetch teamB when there has new changes on repoA and repoB
git pull teamA/master --allow-unrelated-histories
git pull teamB/master --allow-unrelated-histories
#After making changes and commit changes on develop branch
git checkout master
git merge develop

Note: No matter which branch structure you used, you should notice the merge conflicts since the three repos contain same files/code. 注意:无论使用哪种分支结构,您都应该注意到合并冲突,因为三个存储库包含相同的文件/代码。

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

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