使用git分支与多个存储库的好处 [英] Benefits of using git branches vs. multiple repositories

查看:128
本文介绍了使用git分支与多个存储库的好处的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发自动化代码。



我们的代码使公司的产品自动化并同步到特定产品版本。



目前,我们有1个大的Git仓库,里面有多个分支 - v1.0,v1.1,v2.0(版本1.0的自动化在v1.0分支,等等)。



在具有分支的单个存储库中使用这些版本的优点和缺点与将每个版本代码保存在单独的存储库中有什么区别? / strong>



这两种解决方案都可以工作,我所寻找的答案是两种方法的优点/缺点列表。



我知道许多团队正在使用分支来隔离开发中的临时阶段,例如修复错误或新功能,将工作归并到主要开发分支中结束。



我知道的其他工作模式是有不同的分支用于开发,发布等,以将clea这些声音与我们目前正在做的事情类似。




$ b

*请注意,我们制作的某个特定版本中的某些修改与所有产品版本相关,而有些修改则不是这样。 解决方案


  • 只有一个repo来管理(您的自动化指向一个远程)

  • 比较(差异)分支之间可能直接从一个回购

  • 那些从那一个回购的分支到可能需要它的任何其他下游回购



缺点:




  • 分支混乱(您需要管理/删除分支的总和)

  • 标签适用于所有回购(不仅限于某些产品)

    $ b $ h2多次回购

    优点




    • 你可以从主要的仓库中取出你需要的东西并在那里工作

    • 你可以很容易地清理旧的分支(只需删除特定的仓库)



    缺点




    • 回购重复更多的空间)

    • 仓库管理(您需要指向正确的远程仓库)



    • < hr>

      我认为单回购方法是一种更简单,更经典的方法。

      这就是说,如果您拥有很多版本(需要定期清理),在自己的回购中隔离这些临时版本也可以。


      We are doing development for automation code.

      Our code automates the company's products and is synced to a particular product version.

      Currently, we have 1 big Git repository with multiple branches in it - v1.0, v1.1, v2.0 (automation for version 1.0 goes in v1.0 branch, and so on).

      What are the advantages and disadvantages of having these in a single repository with branches vs. keeping each version code in a separate repository ?

      Both solutions can work, the answer i'm looking for is a list of pros/cons for either approach.

      I know that many teams are using branches to isolate temporary stages in development, such as doing a bug fixes or a new feature, merging back the work into the main development branch in the end.

      Other modes of work i know are having different branches for development, release, etc, to separate "cleaner" revisions of the code from dirty ones that are constantly being worked on.

      None of these sound similar to what we are currently doing though.

      *Note that some modifications in a particular version we make are relevant for all product versions, while some are not.

      解决方案

      Multiple branches

      Pros:

      • only one repo to manage (your automate points to one remote)
      • comparison (diff) between branches possible directly from that one repo
      • you can pull any of those branches from that one repo to any other downstream repos which might need it

      Cons:

      • branch cluttering (you need to manage/delete the sum of the branches)
      • tags are for all the repo (not just for "some products"

      Multiple repos

      Pros

      • you can pull from the main repo only what you need and work from there
      • you can clean easily old "branches" (just delete that specific repo)

      Cons

      • repo duplication (takes more space)
      • repo management (you need to point to the right remote(s))

      I would argue the single repo approach is a simpler and more classic approach.
      That said, if you have many versions (which need to be cleaned up regularly), isolating those transient versions in their own repo can work too.

      这篇关于使用git分支与多个存储库的好处的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆