内部开发使用 git 的工作流程描述

发布于 2024-07-25 17:55:32 字数 355 浏览 4 评论 0原文

我工作的公司希望每月发布一次,我正在努力说服他们改用 git。 我相信处理这个问题的正确 git 方式是为每个版本(即每月)建立一个集成分支,并在集成分支上建立功能分支以进行新的开发和更改。 该环境充满了相互依赖性,有时由于其他外部系统所需功能的延迟,某个功能必须推迟到不同的月份。 这些项目通常会在 2-3 个集成分支上并行进行活动,并且活动仅限于一组联系相当密切的人员。 (这意味着我怀疑只要我们在最后一个集成分支上,我们就可以使用变基——对于一半的人来说,至少有一半的时间是这样)

有相当多的人参与其中,所以我真的需要一些直接的如何执行此操作的指南,分支/合并结构的逻辑解释以及执行此操作的实用 git 命令。 有谁知道这样的描述非常适合这样的工作流程?

The company I work for wants to have monthly releases, and I am trying to convince them to switch to git. I believe the proper git-way to handle this is to have a integration branch for each release (i.e. monthly) and have feature branches off the integration branches for new development and changes. The environment is loaded with interdependencies and sometimes a feature has to be postponed to a different month because of delays in required features from other external systems. The projects will generally have activity on 2-3 integration branches in parallel and the activity is confined to a group of people who are in fairly close contact. (Which means I suspect we can use rebasing as long as we're on the last integration branch¸which is true at least half of the time for half of the people)

There's a fair amount of people involved, so I really need some straight guidelines of how to do this, both a logical explanation of the branch/merge structure and the practical git commands to do this. Does anyone know of such a description that is reasonably well fit for such a workflow ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

踏月而来 2024-08-01 17:55:32

分支/合并结构的逻辑解释

该结构基本上遵循您所说的:集成分支,以及功能分支。
在这种工作流程中,关键是要像您一样理解所有开发都不会进入下一个版本。
但对于 DVCS,了解分支是否可以发布和克隆也很关键。

最后一点(发布)将对合并命令产生很大影响
,即:

  • 合并
  • rebase。

每当开发人员必须在任何集成分支上合并他的工作(他从“中央”存储库中提取)时,我会建议:

# switch back to previous release tag (from where feature branches for next release where done)
$ git checkout previousReleaseTag
# create one's own private
$ git checkout -b myIntegrationBranch
# merge or cherry-pick what we want to actually put in the next release
$ git merge... from our feature branch
# rebase that private integration branch on top of actual integration branch
$ git rebase integrationBranch

最后一个变基将重写本地合并的历史记录,但在分支中您无论如何都不会发布(因此没有造成任何伤害)。
一旦所有新功能都正常工作,您可以将该私有分支合并回相关集成分支的当前 HEAD。

“私有分支 - 合并或樱桃选择 - 变基 - 本地解析 - 合并回来”是一个必要的工作流程,因为多个团队必须将他们的工作合并到一个公共分支。 他们需要在将其合并到公共分支之前重播他们想要在私有分支中发布的内容,否则每个团队都可能破坏公共分支的 HEAD 所代表的内容。

问题中的其他详细信息:

a logical explanation of the branch/merge structure

The structure basically follows what you said: an integration branch, and features branches.
In this kind of workflow, it is key to understand, as you did, that all development will not make it to the next release.
But with a DVCS, it is also key to understand a branch can be published and clone.

That last point (publication) will have a big influence on the merge commands
, namely:

  • merge
  • rebase.

Whenever a developer has to merge his work on any integration branch (he pulled from a "central" repository), I would recommend:

# switch back to previous release tag (from where feature branches for next release where done)
$ git checkout previousReleaseTag
# create one's own private
$ git checkout -b myIntegrationBranch
# merge or cherry-pick what we want to actually put in the next release
$ git merge... from our feature branch
# rebase that private integration branch on top of actual integration branch
$ git rebase integrationBranch

The last rebase will rewrite the history of your local consolidations, but in a branch you will not publish anyway (so no harm done).
Once all your new features are working, you can merge back that private branch to the current HEAD of the relevant integration branch.

The "private branch - merge or cherry pick - rebase - local resolution - merge back" is a necessary workflow since several team will have to merge their work to a common branch. They need to replay what they want to publish in a private branch before merging it to the common branch, otherwise each team could break what is represented by the HEAD of the common branch.

Other details in the questions:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文