5

I have tried git submodule. Although it can solve my problem of sharing repository in projects, but using submodule has 2 issues that troubles me:

  1. The submodule folder need to commit if submodule contents has committed changes.
  2. Branch settings is not propagate into submodules. We have to manually switch branch in submodules if works in branches are across submodule.

These 2 problems introduces errors easily for daily development work. I found git slave may solve my problem.

Is there any side effect of using git slave?

Or is there are good practices to avoid the above issue in git submodule?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Chau Chee Yang
  • 18,422
  • 16
  • 68
  • 132

1 Answers1

4

The main point to be aware is quite precely described in the "Gitslave is not perfect" section:

Less obviously, there is a very loose relationship between commits in different repositories.
You cannot easily and precisely determine what commit/SHA any other repository was at when a particular commit was made (though you can approximate and assume pretty easily). Only tags provide exact synchronization between different repositories.

And that is bad in term of reproducibility (one main goal of a VCS: being able to reproduce the state of an environment at any point in its history).
You need to add tags (with a certain naming convention) in order to get back some of the tight correspondence you need between a parent repo and its sub-repos (and which is naturally present with submodules, as I explain in the true natrue of submodules).

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I am reading your explains. What does it meant by "This is called having a detached head — it means the HEAD file points directly to a commit, not to a symbolic reference." I don't understand what is the meaning of "symbolic reference" here. – Chau Chee Yang Jul 01 '11 at 15:28
  • @Chau: see http://stackoverflow.com/questions/3965676/why-did-git-detach-my-head/3965714#3965714 for a visual illustration, and http://stackoverflow.com/questions/2519031/git-head-has-disappeared-want-to-merge-it-into-master or http://stackoverflow.com/questions/999907/git-push-says-everything-up-to-date-even-though-i-have-local-changes for more on detached HEAD. – VonC Jul 01 '11 at 17:03