With git you can use git submodule
.
ProductA can have specific commit_ids (which can be a branch) of some submodules (for example ComponentA, ComponentB, SharedComponentC).
To add a component to ProductA, from the ProductA directory on your development machine do:
C:\projects\ProductA.git\> git submodule add --branch master --name ComponentA http://reposerver.ourcompany.com/ComponentA components/ComponentA
C:\projects\ProductA.git\> git submodule add --branch master --name ComponentB http://reposerver.ourcompany.com/ComponentB components/ComponentB
C:\projects\ProductA.git\> git submodule add --branch ProjectA --name sharedComponentC http://reposerver.ourcompany.com/ComponentC components/sharedComponentC
Other developers can use:
C:\projects\ProductA.git\> git submodule init
C:\projects\ProductA.git\> git submodule update
to receive the correct versions of the submodules in their working directory.
When you make some changes to a submodule, you commit the cangeschanges of the submodule and you commit the new version of the submodule in the project, i.e.:
C:\projects\ProductA.git\components\sharedComponentC\> git add ...
C:\projects\ProductA.git\components\sharedComponentC\> git commit
C:\projects\ProductA.git\components\sharedComponentC\> cd ..\..
C:\projects\ProductA.git\> git add components/sharedComponent
C:\projects\ProductA.git\> git commit
Remarks
- I used commandlinecommand-line syntax to explain how to use git; you are free to use any graphical tool or visual studio plugin that you like.
- I checked the syntax and parameters under linuxLinux and translated the examples to windowWindows command prompt, so there might some mistaksemistakes (e.g. slashedslashes instead of dashes); refer to the git reference manual for the exact syntax.
- names ofThe project dirdirectory (
C:\projects\ProductA.git
), branch name (ComponentA
), repository location (http://reposerver.ourcompany.com/ComponentA
), and submodule directory (components/ComponentA
) can vary independently.