In my project I have a git submodule tracking the repo B
.
When the repo is cloned on a new machine, the git sobmodule seems to track a specific commit, so when new commits are done in the repo B
I have to manually do a pull on main repo, and then commit it, otherwise new clones of the repo will ends up having the submodule to the old commit of the repo B
, is this the normal behavior? Can I make the sobmodule track the HEAD
instead of a specific commit?
Asked
Active
Viewed 94 times
1

rascio
- 8,968
- 19
- 68
- 108
-
Possible duplicate of [Git submodule to track remote branch](https://stackoverflow.com/questions/19986075/git-submodule-to-track-remote-branch) – phd Jun 27 '19 at 12:19
-
https://stackoverflow.com/search?q=%5Bgit-submodules%5D+track+branch – phd Jun 27 '19 at 12:19
-
The short answer: no, whatever you do is the right and the only way. – phd Jun 27 '19 at 12:20
1 Answers
1
This is the normal and expected behavior. Basically, you want to always a predictible state in your working directory after a clone. If the repo B is updated, you have to manually fetch and merge these updates, then test it still works well with your main repo A, and then you can commit on repo A the information "submodule is now on commit XXX".
This avoid unwanted behavior if changes were performed on repo B that you didn't notice. If the submodule were always pointing on "latest commit", you couldn't be sure your project A is always in sync with submodule B.

Antwane
- 20,760
- 7
- 51
- 84