Git submodule mess: how to use git submodules with developers not familiar with git? Git submodule mess: how to use git submodules with developers not familiar with git? windows windows

Git submodule mess: how to use git submodules with developers not familiar with git?


The reason why a submodule points to a particular revision is important. If you point to a HEAD, builds will be unreproducible. I.e. if you checkout yesterday's a version of the Project, you would never know which exact version of source@HEAD was yesterday.

That's why it always stores particular revision sha.

To pull all submodules you could use Easy way pull latest of all submodules


I am not good at Git and submodule. But I think some simple rules would be very helpful.

  1. Commit and push from sub-directory.
  2. Go back to root of your project, check the status if you need to commit and push again.

when Pull. can try to use script to bundle the "pull/submodule update" together. And only do it at the root of your project.


Consider this:

  1. source is pointing to HEAD (as you would want).
  2. you make changes to source inside you Project (you commit but not push them)
  3. now you have two HEADs : one in your Project's source, another in your common source.

Which one you would want to be present in your Project when you make submodule update?

The problem (and the main feature) of git in your case is that you consider commit and push as atomic operation. It isn't. Git is decentralized. There is no common HEAD. You might have multiple repositories with different HEADs.

Consider this:

  1. you have 3 developers (A, B and C) with a git project.
  2. they all pull a project's HEAD.
  3. each developer has made changes to project
  4. now each of them has 3 HEADS: A HEAD, B HEAD and C HEAD.

Which HEAD you consider "true" HEAD?

So, to answer your question: If you want common source submodule always be synchronized with central repository, git isn't your choice. And probably none of VCSs would help you with that.

You should treat git submodule as a thirdparty library which should be updated manually with these two steps:

  1. Pull your submodule ("download thirdparty library")
  2. Commit your project with updated submodule ("place the new version of thirdparty library to your project")

If you want to make changes to submodule you should do the same in reverse order:

  1. Commit your submodule ("make your changes to the thirdparty library")
  2. Push your submodule ("send your changes to the thirdparty library maintainer")
  3. Commit your project with updated submodule ("place the new version of thirdparty library to your project")