Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Subtrees vs Monorepo

We recently decided to move from TFVC to Git and I'm trying to find the best way to design our new Git architecture.

Our code is made of independent but tightly coupled modules, let's look at the following projects:

  • CommonLib1

  • CommonLib2

  • ApplicationA (uses CommonLib1)

  • ApplicationB (uses CommonLib1 & CommonLib2)

Although CommonLib1/CommonLib2 are completely independent, almost every new feature for ApplicationA/ApplicationB would require modifying CommonLib1/CommonLib2.

Moreover, when adding new features we would like to create a single branch that would span between all our projects.

As far as I understand, I'm left with 2 main options:

  1. Create a repo for each project, and add CommonLib1/CommonLib2 as subtrees in ApplicationA/ApplicationB.

  2. Create a single Monorepo for all the projects.

What would be the best Git practice for my situation?

like image 403
Michael Avatar asked Feb 26 '17 18:02

Michael


1 Answers

Since CommonLib1/CommonLib2 are closely related with ApplicationA/ApplicationB, so you’d better use option2 (create a single Monorepo for all projects). The branches structure can be as below:

  • Lib1 branch: manage/develop/update CommonLib1 in this branch. When it’s updated, you can merge it in appA and appB branches.

  • Lib2 branch: manage/develop/update CommonLib2 in this branch. When it’s updated, you can merge it in appB branch.

  • appA branch: manage/develop ApplicationA project.

  • appB branch: manage/develop ApplicationB project.

like image 179
Marina Liu Avatar answered Nov 13 '22 12:11

Marina Liu