Benefits of using git branches vs. multiple repositories

元气小坏坏 提交于 2019-12-05 00:28:17

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.

Charlie Rudenstål

Here's an interesting answer using Git tags and branches from this Stack overflow question: https://stackoverflow.com/a/2714318/1552414 (answer by None-da)

  1. Create a tag when you reach a new version. (v3.0.0)
  2. Create a branch of it when you need to modify it for the first time

    git checkout -b v3.0.0_branch v3.0.0 
    
  3. Commit to the branch and create new tags when you reach v3.0.1, v3.0.2, v3.1.0

Not too long ago my company went through a similar discussion (pros and cons of branches). While doing research I found the following instructional to be helpful. http://guides.beanstalkapp.com/version-control/branching-best-practices.html I hope it helps you as well.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!