I have a single git repository with multiple projects. The code of each project is found under a dedicated subdirectory. Each project has it's own deploy procedure. I would like that when I push a commit under the project's directory it would deploy the right project (and only it). I am currently using bitbucket pipeline, however, it seems, that it doesn't have this option. How can I make this work? ( I can switch to another CI/CD tool )
1 Answers
It does not have this option because this is not how git is used.
For projects that are to be separately deployed there should be one repository each. This will allow you to fine tune the deploy procedures individually in a manageable and documentable way and, even more important, keep the history clean. Imagine now in your situation you need to review a specific project's history - you will end up digging though all the commits of the other projects trying to find the ones you are looking for.
There is a solution though if you need the projects interconnected and under common version control: submodules. Check out the official docu here. It will allow you to keep track of individual histories and share resources at the same time. Also it will give you distinct control over the versions of each project being in the shared space.
So my solution to your problem: Refactor. Separate the projects to individual repositories, each with its own deployment strategy working just fine. If you then need to interconnect them and share resources make them submodules, create a new repository and add them in as submodules. This should solve your hickups with a messed up history and uncontrollable folders.

- 1,389
- 2
- 23
- 27
-
Thanks for the answer, This is actually an old mono vs. multi-repository debate. Suppose that I have 20 different projects, each project is working with other projects, and typically I have about 4 different projects to commit to. At the time when I commit this, someone else can commit to one of my projects, It is too complex to manage all of this with multiple submodules, I would like to have a single master, and that some background work will make sure all the services are deployed. The PR will be managed better in this way, no partial PRs of some submodule. – Alon May 06 '19 at 07:29
-
In order to see the commits that are relevant to a single project, it is really simple, I filter on the right subdirectory, and that's it. – Alon May 06 '19 at 07:29
-
Would hooks help you? – harmonica141 May 06 '19 at 08:09
-
What do you mean? What to do with them? – Alon May 06 '19 at 08:14
-
They can be used to trigger actions on event. Have a look here: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks . Anyway I still think refactoring would be a better solution. Complex interdependencies are not a contraindication for submodules. – harmonica141 May 06 '19 at 08:16