Search code examples
gitgit-submodules

Implementing semantic versioning with git submodules


everyone. I’m working on a project with following structure:

src/
  ExternalLib1/
  ExternalLib2/
  ExternalLib3/
  Main/
  other files…

Where ExternalLibX are git submodules and supported by other developers in my team, Main and other files - is my project.

My .gitmodules file sets all submodule branches to develop branch.

I want to implement git semantic versioning and I can’t figure out how it can be done.

For example: my colleague updates ExternalLibX module from version v1.0.0 to v1.1.0. After that he send a notification about that and I need to update Main project. Now I’m doing it with

cd ExternalLibX
git checkout develop
git pull origin develop

But after that I also need to update the version into Main project, how can I do that?

I can solve it by changing submodule branches from develop to specific commits, and make a version update in Main after any commit sha change in .gitmodules, but it seems not a good solution for me.


Solution

  • I can solve it by changing submodule branches from develop to specific commits

    That is what a submodule is: a specific commit (plus an URL to a remote repository).

    If your colleague creates a tag v1.1.0 on ExternalLib1 (just this one), you need to go to ExternalLib1/ folder, checkout v1.1.0, cd back to src/, add and commit the new state.