DVCS 存储库设计 - 使用分支或单独的存储库将开发与稳定版分开?

发布于 2024-10-14 09:43:22 字数 1349 浏览 3 评论 0 原文

我正在工作中制定一个“行动计划”,将我们的源代码管理从 SourceSafe 6.0(呃)迁移到 git 或 Mercurial(最好是 git ATM)等 DVCS。现在我正在研究未来的存储库设计,即分支布局以及如何配置“中央”/blessed 存储库。

现在,到目前为止,我只是真正使用 git 作为将业余爱好开源代码推送到 GitHub 的一种手段,最近也是为了保留我的在工作中拥有自己的私有存储库,以便我对代码修订拥有比 SourceSafe 允许的更细粒度的控制。不幸的是,除了使用简单的功能分支之外,我还没有在我的存储库中经历过广泛的分支/合并场景或其他半复杂的 git 使用。换句话说,我对 DVCS 没有太多的总体经验,因此我认为我无法预测我们将在此处使用的典型工作流程,因此无法自行创建匹配的存储库设计。

因此,我花了很多时间阅读其他人的 git 工作流程,并尝试将这些策略最好地应用于我们在工作中发布代码的方式。我认为无论如何这都是一个起点,我们可以随着进展而改变它。

现在,在查看了许多 git 工作流程之后,我真的很喜欢一个特定的 概述作者:Vincent Driessen,它似乎有一个非常干净的分支布局,非常适合我们在工作中进行部署的方式(或者无论如何应该):

使用分支分离开发/稳定


Separate Dev/Stable using Branches

但是,我承认在看到 Joel Spolsky 的 HgInit 站点,该站点似乎更关注单独的存储库,而不是用于分离开发和稳定代码的分支:

Separate Dev/Stable using Repos


Separate Dev/Stable using Repos

问题


这个以存储库为中心的分离层是否只是一个 Mercurial 的东西,在 git 中使用不多?如果不是,那么与使用分支来分离开发/稳定代码相比,使用此方法有哪些优点/缺点?或者我完全误解了这里发生的事情? :-)

如有任何意见,我们将不胜感激;如果由于我的无知而导致这个问题浪费时间,我提前道歉。

I'm working on a "plan of action" at my job for migrating our source control from SourceSafe 6.0 (ugh) to a DVCS like git or Mercurial (preferably git ATM). Right now I am working on the future repository design, i.e. branch layout and how to configure the 'central'/blessed repo(s).

Now, insofar I have only really used git as a means to push hobby open source code to GitHub and more recently for keeping my own private repo at work so that I have more fine-grained control over my code revisions than SourceSafe allows. Unfortunately I have yet to experience a wide gamut of branching/merging scenarios or other semi-complex git usage in my repos besides using simple feature branches. In other words, I don't have a lot of overall experience with DVCS', so I don't think I can predict the typical workflow we will use here and therefore am unable to create a matching repository design on my own.

So instead, I have spent a lot of time reading other people's git workflows and trying to best apply those strategies to how we release code at my job. I figure it's a place to start anyway, and we can change it as we go along.

Now, after looking at many git workflows, I am really liking a particular one outlined by Vincent Driessen, which seems to have a very clean branch layout that is a near-fit for how we do deployments at work (or should, anyway):

Separate Dev/Stable Using Branches


Separate Dev/Stable Using Branches

However, I admit to being a little confused after seeing a little different example on Joel Spolsky's HgInit site, which seems to focus more on separate repositories rather than branches for separating dev and stable code:

Separate Dev/Stable Using Repos


Separate Dev/Stable Using Repos

Questions


Is this repository-focused separation layer simply a Mercurial thing that isn't used much with git? If not, then what are the advantages/disadvantages to using this method over the use of branches for separating dev/stable code? Or am I simply completely misunderstanding what is going on here? :-)

Any input would be appreciated; I apologize in advance if this question is a waste of time due to my being steeped in ignorance.

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

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

发布评论

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

评论(2

策马西风 2024-10-21 09:43:22

最后,这完全取决于您的喜好。我喜欢乔尔所涵盖的分支模型的克隆,但它们都是有效的。这是一篇很棒的文章,涵盖了 Mercurial 和 Git 中的一些不同的分支模型(尽管有标题):

http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/

我最大的建议是不要过度思考它。我知道你需要一个管理层可以接受的具体建议,但如果我的经历在你所在的地方重演,你会发现人们非常认真地对待去中心化的部分。您将有临时团队在网络共享方面做一些额外的工作,您将有开发人​​员到开发人员的克隆和拉动,以及各种临时组织。只要你有几个关键的回购协议,并且有坚定、明确的期望(例如:“必须编译”或“必须可交付”或“必须得到吉姆的祝福”),你就会没问题。

In the end it's all about your preferences. I like the clones as branches model Joel covers, but they're both valid. Here's a great article that covers a few different branching models in both Mercurial and Git (despite the title):

http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/

My biggest piece of advice is to not over think it. I know you need a concrete proposal that management can buy in to, but if my experience repeats itself where you are you'll find that people are taking the decentralized piece pretty seriously. You'll have impromptu teams doing little side efforts on network shares, you'll have dev-to-dev cloning and pulling, and all sorts of ad hoc organization. So long as you have a few key repos with firm, clear expectations (e.g.: "must compile" or "must be shippable" or "must have Jim's blessing") you'll be fine.

习ぎ惯性依靠 2024-10-21 09:43:22

我对此的感觉是,你应该避免从除了你最好的测试过的东西之外的任何东西分支。这意味着所有分支都应该来自版本中的修订版。

这样做的原因是双重的。首先,当功能分支中出现错误时,您想知道该错误是该功能的结果,而不是代码中的错误。其次,当您想要发布功能时,您不想强制进行与您的功能无关的任何更改。

我们在工作中采用了一种我称之为“浓密分支”策略的策略。

基本上有功能分支、发布分支、修补程序分支和主分支。所有功能分支都必须有一个在其基础上的主分支中标记的修订版,并且它们在任何时候都不得与其他功能分支合并。不过,它们可能会与主分支中未来的标记修订合并。

一旦某个功能准备就绪,它就会合并到发布分支中进行测试。一旦经过测试,它就会进入主分支。修补程序的处理方式与您在图表中绘制的方式大致相同。

最后,我们有一个一次性的“集成”分支。该分支很大程度上自动合并了可能很快发布的所有功能。该分支需要接受日常构建测试,但不一定与发布分支具有相同级别的严格测试。这是为了在此过程的早期发现功能交互错误。

我是一个善变的人。所以我不认为“分支”和“存储库”之间确实存在显着区别。事实上,对于大多数事情,我不太喜欢多个分支存储库,因为它可以很容易地合并到您实际上不想使用的分支中。我宁愿我的仓库中根本没有修订。

My feeling on this is that you should avoid branching from anything but your best tested stuff. This means that all branches should be from a revision that in releases.

The reasoning for this is twofold. First, when you have a bug in a feature branch, you want to know that the bug is a result of the feature, not because of a bug in the code. Secondly, when you want to release your feature, you don't want to force any changes to come along that aren't really related to your feature.

We've gone to a strategy at work that I call the 'bushy branch' strategy.

Basically there are feature, release, hotfix and master branches. All feature branches must have a revision that was tagged in the master branch at their base and they may not merge with other feature branches at any point. They may merge with future tagged revisions in the master branch though.

Once a feature is ready, it's merged into the release branch for testing. Once it's tested, it goes into the master branch. Hotfixes are treated much as you diagram them out in your diagram.

Lastly, we have a throwaway 'integration' branch. This branch is largely automated merges of all the features that may be released soon. This branch is subjected to the daily build tests, but not necessarily the same level of rigorous testing that the release branch is. It's to catch feature interaction bugs early in the process.

I'm a Mercurial person. So I do not see that there is really a significant distinction between 'branch' and 'repository'. I, in fact, do not really like multiple branch repositories for most things as it can make it too easy to merge in branches you don't actually want to be working with. I'd rather just not have the revisions in my repo at all.

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